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) { ... });
sort mongoose response
Blah.find({}).sort({date: -1}).execFind(function(err,docs){ //code }); -1 for descending & 1 for ascending
Source: stackoverflow.com