Skip to content

Commit 99fb4b8

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-25088-sort-update (BACKPORT) (#1978)
* DOCSP-24951 regex updates (#1771) * DOCSP-24951-regex-updates * DOCSP-24951-regex-updates * DOCSP-24951-regex-updates * DOCSP-24951-regex-updates Co-authored-by: jason-price-mongodb <[email protected]> * DOCSP-24951 regex updates * DOCSP-25088-sort-update (#1973) * 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 73ca72c commit 99fb4b8

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
@@ -104,7 +104,7 @@ array and then sorts all the elements of the array by the ascending
104104
``quizzes``; i.e. ``{ score: 1 }`` and **not** ``{ "quizzes.score": 1}``
105105

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

109109
.. code-block:: javascript
110110

@@ -128,7 +128,7 @@ A collection ``students`` contains the following document:
128128

129129
{ "_id" : 2, "tests" : [ 89, 70, 89, 50 ] }
130130

131-
The following operation adds two more elements to the ``scores`` array
131+
The following operation adds two more elements to the ``tests`` array
132132
and sorts the elements:
133133

134134
.. code-block:: javascript
@@ -138,7 +138,7 @@ and sorts the elements:
138138
{ $push: { tests: { $each: [ 40, 60 ], $sort: 1 } } }
139139
)
140140

141-
The updated document has the elements of the ``scores`` array in
141+
The updated document has the elements of the ``tests`` array in
142142
ascending order:
143143

144144
.. code-block:: javascript
@@ -156,7 +156,7 @@ A collection ``students`` contains the following document:
156156

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

161161
.. code-block:: javascript
162162

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

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

171170
.. code-block:: javascript
172171

@@ -177,5 +176,5 @@ Use ``$sort`` with Other ``$push`` Modifiers
177176

178177
.. include:: /includes/example-push-with-multiple-modifiers.rst
179178

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

0 commit comments

Comments
 (0)