Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions source/reference/operator/aggregation/sort.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ option in :method:`db.collection.aggregate()` method and the

:pipeline:`$sort` operator can take advantage of an index when
placed at the **beginning** of the pipeline or placed **before**
the following aggregation operators: :pipeline:`$project`,
:pipeline:`$unwind`, and :pipeline:`$group`.

the :pipeline:`$project`,
:pipeline:`$unwind`, and :pipeline:`$group` aggregation operators.
If :pipeline:`$project`, :pipeline:`$unwind`, or :pipeline:`$group`
occur prior to the :pipeline:`$sort` operation, :pipeline:`$sort`
cannot use any indexes.

.. todo:: if a sort precedes the first $group in a sharded system,
all documents must go to the mongos for sorting.