-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Trivial - P5
-
Affects Version/s: None
-
Component/s: Querying
-
Query Execution
-
Fully Compatible
I have a use-case where I am querying an array of ObjectIDs. For example:
db.things.find({
_id:
})
I'd like the results to be ordered by `_id.$in`. Right now I'm resorting to client-side sorting, which kind of sucks since it requires converting between ObjectIDs and strings among other hacks.
A special sorting option like this would be awesome (similar to $natural):
db.things.find({}).sort({
$in:
})
Although the attribute being `$in`ed need not be `_id`, it should be unique (and thus indexed).
Some related questions on StackOverflow:
http://stackoverflow.com/questions/3142260/order-of-responses-to-mongodb-in-query
http://stackoverflow.com/questions/11839515/comparing-and-sorting-mongodb-objectids-in-node-convert-to-string
- is duplicated by
-
SERVER-22193 Allow returning documents in the same order as $in
- Closed
-
SERVER-20788 Ordering results from $in query -- can Aggregation handle this ?
- Closed
- is related to
-
SERVER-32947 Does mongodb $lookup operator ruins default array order?
- Closed