How to sort data using MongoDB Compass How to sort data using MongoDB Compass mongodb mongodb

How to sort data using MongoDB Compass


Using MongoDB Compass 1.7 or newer, you can sort (and project, skip, or limit) results by choosing the Documents tab and expanding the Options.

enter image description here

To sort in ascending order by a field myField, use { myField:1 }. Any of the usual cursor sort() options can be provided, including ordering results by multiple fields.

Note: options like sort and skip are not available in the default Schema tab because this view uses sampling to find a random set of documents, as opposed to the Documents view which displays a specific query result.