sorting by
{array : 1}does not appear to do anything, it returns the same results as just running find(). This issue does not appear to exist in 1.8.4
> db.things.insert({ array: [ [0, ""], [3, "3"] ] }) > db.things.insert({ array: [ [0, ""], [1, "1"] ] }) > db.things.insert({ array: [ [0, ""], [4, "4"] ] }) > db.things.insert({ array: [ [0, ""], [5, "5"] ] }) > db.things.insert({ array: [ [0, ""], [2, "2"] ] }) > db.things.find() { "_id" : ObjectId("4ecb2dbc0ac2d0b3fe518048"), "array" : [ [ 0, "" ], [ 3, "3" ] ] } { "_id" : ObjectId("4ecb2dc20ac2d0b3fe518049"), "array" : [ [ 0, "" ], [ 1, "1" ] ] } { "_id" : ObjectId("4ecb2dc70ac2d0b3fe51804a"), "array" : [ [ 0, "" ], [ 4, "4" ] ] } { "_id" : ObjectId("4ecb2dcb0ac2d0b3fe51804b"), "array" : [ [ 0, "" ], [ 5, "5" ] ] } { "_id" : ObjectId("4ecb2dcf0ac2d0b3fe51804c"), "array" : [ [ 0, "" ], [ 2, "2" ] ] } > db.things.find().sort({ array: 1 }) { "_id" : ObjectId("4ecb2dbc0ac2d0b3fe518048"), "array" : [ [ 0, "" ], [ 3, "3" ] ] } { "_id" : ObjectId("4ecb2dc20ac2d0b3fe518049"), "array" : [ [ 0, "" ], [ 1, "1" ] ] } { "_id" : ObjectId("4ecb2dc70ac2d0b3fe51804a"), "array" : [ [ 0, "" ], [ 4, "4" ] ] } { "_id" : ObjectId("4ecb2dcb0ac2d0b3fe51804b"), "array" : [ [ 0, "" ], [ 5, "5" ] ] } { "_id" : ObjectId("4ecb2dcf0ac2d0b3fe51804c"), "array" : [ [ 0, "" ], [ 2, "2" ] ] } > db.things.find().sort({ array: -1 }) { "_id" : ObjectId("4ecb2dcb0ac2d0b3fe51804b"), "array" : [ [ 0, "" ], [ 5, "5" ] ] } { "_id" : ObjectId("4ecb2dc70ac2d0b3fe51804a"), "array" : [ [ 0, "" ], [ 4, "4" ] ] } { "_id" : ObjectId("4ecb2dbc0ac2d0b3fe518048"), "array" : [ [ 0, "" ], [ 3, "3" ] ] } { "_id" : ObjectId("4ecb2dcf0ac2d0b3fe51804c"), "array" : [ [ 0, "" ], [ 2, "2" ] ] } { "_id" : ObjectId("4ecb2dc20ac2d0b3fe518049"), "array" : [ [ 0, "" ], [ 1, "1" ] ] }
- is duplicated by
-
SERVER-19497 Sort is not done on embedded field
- Closed