sortinglokijs

LokiJs collection find return list in Ascending order


How do i get to sort a loki js collection in a ascending order

var categoryCollection = offlineDb.getCollection('Category');
var catColl = categoryCollection.find({ 'Id': { '$ne': null } });

I debug and i see that the $loki is also in the reverse order . This returns the list in a reverse order ! How can i perform a find with the list in ascending order ? Isnt it by default when you do a find return in a ascending order ?


Solution

  • You have two ways of sorting the result: either by passing your own sorting function in sort(fun), or using simplesort(property [, isdesc]) the second parameter being the ascending/descending order flag. See here