5

I have client side only (local) Meteor collection defined like that (coffeescript):

Products = new Meteor.Collection null

However when I try to find() providing sorting parameters Meteor tells me that sorting of local collections is not supported. This is understandable.

I would like to know what is the easiest/simplest way to get sorted results. Essentially I always use all the data in the Collection, so keeping it in sorted state would solve the problem.

babbata
  • 1,644
  • 3
  • 19
  • 27

1 Answers1

6

It works for me, are you using the latest version of Meteor? Running this code works on the Meteor Docs site:

var foos = new Meteor.Collection( null );
for ( var i = 0; i < 100; i++ ) {
  foos.insert({ num: i });
}
foos.findOne( {} ).num; // => 0
foos.findOne( {}, { sort: [[ "num", "desc" ]] } ).num; // => 99
sbking
  • 7,630
  • 24
  • 33
  • It indeed works. Must have tried it in an older version. Thanks to both of you for the swift responses. – babbata Dec 07 '13 at 17:33