OverviewThe $sort pipeline operator sorts its input documents. Specificationdb.<collection-name>.aggregate(
{ $sort : { <sort-key> } }
);
$sort requires a sort key. Sort key specifications are exactly the same as those for db.sortex.aggregate(
{ $sort : { b : -1, a: 1 } }
);
Here, the output will be the sorted collection, sorted by "b" descending, and "a" ascending. NotesThe $sort operator cannot produce any output documents until it has seen all of its input. It will exhaust the prior pipeline operator's output, sort what it has received, and then be ready to produce output. At the present time, sorts must fit in memory, so sorting a large input stream may not work. |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus