mongoose find with sort code example
Example 1: mongoose find sort
Post.find({}).sort('test').exec(function(err, docs) { ... });
Post.find({}).sort([['date', -1]]).exec(function(err, docs) { ... });
Post.find({}).sort({test: 1}).exec(function(err, docs) { ... });
Post.find({}, null, {sort: {date: 1}}, function(err, docs) { ... });
Example 2: sort mongoose response
Blah.find({}).sort({date: -1}).execFind(function(err,docs){
//code
});
-1 for descending & 1 for ascending