My MongoDB document structure:
_id:ObjectId("12345")
hai:Array
0:Object
designation:"software"
1:Object
designation:"hardware"
2:Object
designation:"Core"
I need to sort the designation in hai array. I tried like this, but not working
db.collection.find({_id:ObjectId("12345")}).sort(hai:-1)
db.collection.find({_id:ObjectId("12345")}).sort(hai.designation:-1)
Can anyone please help, Thanks in advance