please can anyone tell me if $match used in aggregating , changes the order in the result :
I was trying the below query
db.getCollection('fields').aggregate([
{
$match: {
surveyFieldUniqueId: {$in:[ ObjectId("5a33"),
ObjectId("5a35"),
ObjectId("5a37"),
ObjectId("5a39"),
ObjectId("5a3b"),
ObjectId("5a56")
]},
survey: ObjectId("5a24")
}
}
])
the result is in order: 5a56 , 5ba33 , 5a35 , 5a37 , 5a39 , 5a3b
How ever if i remove the second attribute in match i.e survey i get the result in the right order as provided in the $in . I have checked the mongo docs but was unable to find much regarding this . Is there any way to maintain the order sent in the result.