-
Type:
Bug
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
ALL
We should clearly define the sort semantics for unindexed arrays. There's a discrepancy here:
> db.g.find().sort({a:-1}) { "_id" : ObjectId("4f88436904495dab8a55071c"), "a" : [ 4 ] } { "_id" : ObjectId("4f88436804495dab8a55071b"), "a" : [ 3 ] } { "_id" : ObjectId("4f88436704495dab8a55071a"), "a" : [ 2 ] } { "_id" : ObjectId("4f88436504495dab8a550719"), "a" : [ 1 ] } { "_id" : ObjectId("4f88438604495dab8a55071d"), "a" : [ 1, 1 ] } { "_id" : ObjectId("4f88439c04495dab8a55071e"), "a" : [ 1, 1, 0 ] } { "_id" : ObjectId("4f88440204495dab8a55071f"), "a" : [ 1, 1, 0, 1 ] } { "_id" : ObjectId("4f88441104495dab8a550720"), "a" : [ 1, 1, 1, 1 ] } > db.g.find().sort({a:1}) { "_id" : ObjectId("4f88439c04495dab8a55071e"), "a" : [ 1, 1, 0 ] } { "_id" : ObjectId("4f88440204495dab8a55071f"), "a" : [ 1, 1, 0, 1 ] } { "_id" : ObjectId("4f88436504495dab8a550719"), "a" : [ 1 ] } { "_id" : ObjectId("4f88438604495dab8a55071d"), "a" : [ 1, 1 ] } { "_id" : ObjectId("4f88441104495dab8a550720"), "a" : [ 1, 1, 1, 1 ] } { "_id" : ObjectId("4f88436704495dab8a55071a"), "a" : [ 2 ] } { "_id" : ObjectId("4f88436804495dab8a55071b"), "a" : [ 3 ] } { "_id" : ObjectId("4f88436904495dab8a55071c"), "a" : [ 4 ] }
It seems that the reverse sort should mirror the forward sort, but it doesn't.