I have a document with an array field that contains a list of values and I would like to sort by the first element in the array.
{
field1 : "bla",
field2 : "bla",
field3 : "bla",
someArray : [123, 456, 789]
}
I was trying to query like this:
db.testCollection.find({}).sort({"someArray[0]" : 1})
But this does not seem to have any effect and the sort gets ignored.
Is there any way this can be done?