$sort
The `$sort` modifier orders the elements of an array during a $push operation.
Syntax
{
$push: {
field: {
$each: [ <value1>, <value2>, ... ],
$sort: <sort specification>
}
}
}
Parameters
field
stringrequiredThe field to update.
<sort specification>
objectrequiredA document that specifies the field or fields to sort by and the respective sort order. Use 1 for ascending, -1 for descending.