Pipeline Practice

MongoDB $sort

Reorder documents by one or more fields.

Use `1` for ascending order and `-1` for descending order. Put it before `$limit` when you need the highest or lowest results from the full stream.

Stages are the top-level steps in a pipeline. Each stage receives documents, changes the stream in one specific way, and passes its output to the next stage.

Course use: Exercises 03, 07, 08, 11, 12, and Hard Mode 13.

Example pipeline syntax

{ $sort: { total: -1, createdAt: 1 } }