Skip to content

Commit 4801ae2

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-25088-sort-update (#1973) (#1976)
* 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 7b30992 commit 4801ae2

File tree

1 file changed

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

1 file changed

+7
-9
lines changed

source/reference/operator/update/sort.txt

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

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

113113
.. code-block:: javascript
114114

@@ -132,7 +132,7 @@ Add the following document to the ``students`` collection:
132132

133133
db.students.insertOne( { "_id" : 2, "tests" : [ 89, 70, 89, 50 ] } )
134134

135-
The following operation adds two more elements to the ``scores`` array
135+
The following operation adds two more elements to the ``tests`` array
136136
and sorts the elements:
137137

138138
.. code-block:: javascript
@@ -142,7 +142,7 @@ and sorts the elements:
142142
{ $push: { tests: { $each: [ 40, 60 ], $sort: 1 } } }
143143
)
144144

145-
The updated document has the elements of the ``scores`` array in
145+
The updated document has the elements of the ``tests`` array in
146146
ascending order:
147147

148148
.. code-block:: javascript
@@ -160,7 +160,7 @@ Add the following document to the ``students`` collection:
160160

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

165165
.. code-block:: javascript
166166

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

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

175174
.. code-block:: javascript
176175

@@ -181,6 +180,5 @@ Use ``$sort`` with Other ``$push`` Modifiers
181180

182181
.. include:: /includes/example-push-with-multiple-modifiers.rst
183182

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

0 commit comments

Comments
 (0)