Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
Fully Compatible
-
QE 2021-11-15
-
(copied to CRM)
Description
Syntax:
{$project:{orderedArray:{$sort:{path:<array-returning-expression>[, sortBy:<someFieldInArray>, <ascending-vs-descending-option>]}}
|
Examples it should work on:
Input: {a: [ 1, 10, 5, 3 ]}
|
{newA:{$sort:{path:"$a"}}}
|
returns: { newA: [ 1, 3, 5, 10 ] }
|
|
Input: { a: [ { x:1, y:99 }, { x: 9, y: 4 } ] }
|
{newA: {$sort:{path:"$a", sortBy: "$a.y" }}}
|
returns: { newA: [ { x: 9, y: 4 }, { x:1, y:99 } ] }
|
Attachments
Issue Links
- is depended on by
-
SERVER-46372 Use unordered object comparison in aggregation for finding inconsistent sharded indexes
-
- Closed
-
- is duplicated by
-
SERVER-42784 Allow sorting arrays as an aggregation operation
-
- Closed
-
- is related to
-
SERVER-60967 Implement $sortArray in SBE
-
- Closed
-
- links to