Skip to content

Commit 78824a2

Browse files
author
Dave
authored
DOCSP-19443 add an arraySort expression v5.2 (#147)
* DOCSP-19443 Add an array sort expression * First example * Upstream merge conflict * First pass * TOC links * Fake * Undo fake * Table alignment * Staging Tweaks * Review suggestions * Review comments * Review comments
1 parent 767c1e8 commit 78824a2

File tree

5 files changed

+408
-0
lines changed

5 files changed

+408
-0
lines changed

source/includes/extracts-agg-operators.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ content: |
234234
235235
- Returns a subset of an array.
236236
237+
* - :expression:`$sortArray`
238+
239+
- Sorts the elements of an array.
240+
237241
* - :expression:`$zip`
238242
239243
- Merge two arrays together.

source/reference/operator/aggregation.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ Alphabetical Listing of Expression Operators
953953

954954
- Returns a subset of an array.
955955

956+
* - :expression:`$sortArray`
957+
- Sorts an array based on its elements.
956958

957959
* - :expression:`$split`
958960

@@ -1301,6 +1303,7 @@ Alphabetical Listing of Expression Operators
13011303
/reference/operator/aggregation/sin
13021304
/reference/operator/aggregation/sinh
13031305
/reference/operator/aggregation/slice
1306+
/reference/operator/aggregation/sortArray
13041307
/reference/operator/aggregation/split
13051308
/reference/operator/aggregation/sqrt
13061309
/reference/operator/aggregation/stdDevPop

source/reference/operator/aggregation/setUnion.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ Behavior
6767

6868
[ [ "a", "b" ], "b", "a" ]
6969

70+
.. note::
71+
72+
Starting in MongoDB 5.2, the sort order for :expression:`$setUnion`
73+
is undefined. To sort an array, refer to :expression:`$sortArray`.
74+
7075
Example
7176
-------
7277

@@ -109,3 +114,4 @@ The operation returns the following results:
109114
{ "A": [ "red", "blue" ], "B": [ [ "red", "blue" ] ], "allValues": [ "blue", "red", [ "red", "blue" ] ] }
110115
{ "A": [ ], "B": [ ], "allValues": [ ] }
111116
{ "A": [ ], "B": [ "red" ], "allValues": [ "red" ] }
117+

0 commit comments

Comments
 (0)