[Resolved] Bug in Minimongo sorting

I am experiencing a bug in minimongo when trying to sort a collection. The bug only happens in part of the collection was subscribed (on the template level) on a master template view and then you navigate to another view that displays the entire (filtered) collection. I.e. notifications of a new activity vs viewing the entire list of activities

Activity.find({}, { $sort : { createdAt : -1 }});

Its kinda of odd that this is happening but for now I was able to fix it using underscorejs to sort

_(Activity.find({}).fetch()).sortBy(function (num) { return num.createdAt; });

It is not a bug. The sort syntax is different in meteor (both on server and on client) and it is passed within an options object as described in http://docs.meteor.com/#/full/find

So what you should do is:

Activity.find({}, { sort : { createdAt : -1 }});
1 Like

Wooow… thank you. I didn’t even think of that.

1 Like