Is there a way to sort sub docs in a mongo query? Example(Blog Collection):
{
"_id" : ObjectId("4c69d19532f73ad544000001"),
"content" : "blah blah blah",
"comments" : {
{"author": "jim", "content":"comment content 1", "date" : "07-24-1995"},
{"author": "joe", "content":"comment content 2", "date" : "07-24-1996"}
{"author": "amy", "content":"comment content 3", "date" : "09-10-1999"}
}
}
{
"_id" : ObjectId("4c69d19532f73ad544000002"),
"content" : "blah blah blah",
"comments" : {
{"author": "jim", "content":"comment content 1", "date" : "07-24-1995"},
{"author": "joe", "content":"comment content 2", "date" : "07-24-1996"}
{"author": "amy", "content":"comment content 3", "date" : "07-24-1997"}
}
}
I want to get my blog posts ordered in however way I deiced and then have comments ordered within my blog posts by reverse order by date or any other sorting I want.. Is that not possible with mongoDB?