Skip to content

Commit ed2ec13

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-25088-sort-update (#1973) (#1977)
* DOCSP-25088-sort-update * DOCSP-25088-sort-update * DOCSP-25088-sort-update Co-authored-by: jason-price-mongodb <[email protected]> Co-authored-by: jason-price-mongodb <[email protected]>
1 parent bd2784a commit ed2ec13

File tree

1 file changed

+7
-8
lines changed
  • source/reference/operator/update

1 file changed

+7
-8
lines changed

source/reference/operator/update/sort.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ array and then sorts all the elements of the array by the ascending
106106
``quizzes``; i.e. ``{ score: 1 }`` and **not** ``{ "quizzes.score": 1}``
107107

108108
After the update, the array elements are in order of ascending
109-
``score`` field.:
109+
``score`` field:
110110

111111
.. code-block:: javascript
112112

@@ -130,7 +130,7 @@ A collection ``students`` contains the following document:
130130

131131
{ "_id" : 2, "tests" : [ 89, 70, 89, 50 ] }
132132

133-
The following operation adds two more elements to the ``scores`` array
133+
The following operation adds two more elements to the ``tests`` array
134134
and sorts the elements:
135135

136136
.. code-block:: javascript
@@ -140,7 +140,7 @@ and sorts the elements:
140140
{ $push: { tests: { $each: [ 40, 60 ], $sort: 1 } } }
141141
)
142142

143-
The updated document has the elements of the ``scores`` array in
143+
The updated document has the elements of the ``tests`` array in
144144
ascending order:
145145

146146
.. code-block:: javascript
@@ -158,7 +158,7 @@ A collection ``students`` contains the following document:
158158

159159
To update the ``tests`` field to sort its elements in descending
160160
order, specify the ``{ $sort: -1 }`` and specify an empty array ``[]``
161-
for the :update:`$each` modifier, as in the following:
161+
for the :update:`$each` modifier. For example:
162162

163163
.. code-block:: javascript
164164

@@ -167,8 +167,7 @@ for the :update:`$each` modifier, as in the following:
167167
{ $push: { tests: { $each: [ ], $sort: -1 } } }
168168
)
169169

170-
The result of the operation is to update the ``scores`` field to sort
171-
its elements in descending order:
170+
The example sorts the ``tests`` field values in descending order:
172171

173172
.. code-block:: javascript
174173

@@ -179,5 +178,5 @@ Use ``$sort`` with Other ``$push`` Modifiers
179178

180179
.. include:: /includes/example-push-with-multiple-modifiers.rst
181180

182-
The order of the modifiers is immaterial to the order in which the
183-
modifiers are processed. See :ref:`push-modifiers` for details.
181+
The order of the modifiers in the query does not change the order that
182+
the modifiers are applied. For details, see :ref:`push-modifiers`.

0 commit comments

Comments
 (0)