Can someone tell me how I can sort an array of items according to date and time. Currently, I am using
image.find({reviewed:true }, null, {sort:{"submittedDate":-1}},
function (err, images) {})
My schema for date is:
submittedDate: Thu, 08 Nov 2012 15:42:47 GMT
But it sort only date wise. I want to sort first by time then by date.
Any help will be appreciated.
The way to sort would be:
image.find({reviewed:true})
.sort({'submittedDate': 'desc'})
.exec(function(err, images) {
//do stuff with images
});
From v3.8.1, the syntax would be:
image.find({reviewed:true})
.sort('submittedDate', -1)
.execFind(function(err, images) {
});