How sort an array in a collection
问题 I've been looking for sorting a specific inner array in a collection, I use doctrine-mongodb-bundle in symfony2. My collection : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"A", "pos": 2}, {"name":"B", "pos": 7}, {"name":"C", "pos": 1}, {"name":"D", "pos": 5} ] }] } I wish I had : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"C", "pos": 1}, {"name":"A", "pos": 2}, {