# Sorting and Paging Results

sort puts a query's results in order, skip and limit cut out one page of them, and countDocuments counts every match, so an API can answer with page 2 of 3 instead of every document at once.

![Cheat sheet: Sorting and Paging Results](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/df099daa98064ceda916522d3e8a6074.webp)

- Category: Node.js
- Level: Journeyman
- Tags: countDocuments, mongodb, nodejs, nosql, Pagination, sort, limit and skip
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-mongodb-sort-and-paging-cheat-sheet
