Skip to content
Justice Tech School

$sort, $limit, $skip

Order and slice in a pipeline.

Example
db.sales.aggregate([
  { $sort: { amount: -1 } },
  { $skip: 10 },
  { $limit: 5 }
])

Exercise

Top results.

{ : 5 }

Quiz Test

Why sort before limit?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.