In MongoDB, the $orderBy query modifier sorts the results of a query in ascending or descending order.
$orderBy accepts a document that specifies the field to sort, and the sort order. The sort order can be either 1 for ascending or -1 for descending.
$orderBy has been deprecated in the mongo shell since v3.2. Use the cursor.sort() method instead.