๐ง $sort stage:
With the $sort stage we can sort input documents or output documents from stage to ascending or descending order.
๐ Syntax:
db.collection.aggregate([{$sort: {<field> = < -1 | 1 >, <field2>: < -1 | 1 >...}} ])
Here, -1 represents the descending order and 1 represents the ascending order.
Stage order:
$match --> $group --> $sort --> $count
Post a Comment