@@ -119,10 +119,10 @@ parameters and the locales they are associated with, see
119119
120120 - boolean
121121
122- - Optional. Flag that determines whether to include case comparison at
123- ``strength`` level ``1`` or ``2``.
122+ - Optional. Flag that determines whether to include case comparison
123+ at ``strength`` level ``1`` or ``2``.
124124
125- If ``true``, include case comparison; i.e.
125+ If ``true``, include case comparison:
126126
127127 - When used with ``strength:1``, collation compares base characters
128128 and case.
@@ -176,12 +176,15 @@ parameters and the locales they are associated with, see
176176 - Optional. Flag that determines whether to compare numeric strings as numbers
177177 or as strings.
178178
179- If ``true``, compare as numbers; i.e. ``"10"`` is greater than
180- ``"2"``.
179+ If ``true``, compare as numbers. For example,
180+ ``"10"`` is greater than ``" 2"``.
181181
182- If ``false``, compare as strings; i.e. ``"10"`` is less than ``"2"``.
182+ If ``false``, compare as strings. For example,
183+ ``"10"`` is less than ``"2"``.
183184
184185 Default is ``false``.
186+
187+ See :ref:`numericOrdering Restrictions <numeric-order-restrictions>`.
185188
186189
187190
@@ -237,12 +240,12 @@ parameters and the locales they are associated with, see
237240
238241 * - ``"punct"``
239242
240- - Both whitespace and punctuation are " ignorable", i.e. not
243+ - Both whitespace and punctuation are ignorable and not
241244 considered base characters.
242245
243246 * - ``"space"``
244247
245- - Whitespace are " ignorable", i.e. not considered base
248+ - Whitespace is ignorable and not considered to be base
246249 characters.
247250
248251
@@ -334,7 +337,100 @@ Collation and Unsupported Index Types
334337.. include:: /includes/extracts/collation-index-type-restrictions.rst
335338
336339.. include:: /includes/extracts/collation-index-type-restrictions-addendum.rst
340+
341+ Restrictions
342+ ------------
343+
344+ .. _numeric-order-restrictions:
345+
346+ numericOrdering
347+ ~~~~~~~~~~~~~~~
348+
349+ When specifying the ``numericOrdering`` as ``true`` the following
350+ restrictions apply:
351+
352+ - Only contiguous non-negative integer substrings of digits are
353+ considered in the comparisons.
354+
355+ ``numericOrdering`` does not support:
356+
357+ - ``+``
358+ - ``-``
359+ - decimal separators, like decimal points and decimal commas
360+ - exponents
361+
362+ - Only Unicode code points in the Number or Decimal Digit (Nd) category
363+ are treated as digits.
364+
365+ - If a digit length exceeds 254 characters, the excess characters are
366+ treated as a separate number.
367+
368+ Consider a collection with the following string number and decimal
369+ values:
370+
371+ .. code-block:: javascript
372+ :emphasize-lines: 6,10
373+
374+ db.c.insertMany(
375+ [
376+ { "n" : "1" },
377+ { "n" : "2" },
378+ { "n" : "2.1" },
379+ { "n" : "-2.1" },
380+ { "n" : "2.2" },
381+ { "n" : "2.10" },
382+ { "n" : "2.20" },
383+ { "n" : "-10" },
384+ { "n" : "10" },
385+ { "n" : "20" },
386+ { "n" : "20.1" }
387+ ]
388+ )
389+
390+ The following :method:`find <db.collection.find()>` query uses a
391+ collation document containing the ``numericOrdering`` parameter:
392+
393+ .. code-block:: javascript
394+
395+ db.c.find(
396+ { }, { _id: 0 }
397+ ).sort(
398+ { n: 1 }
399+ ).collation( {
400+ locale: 'en_US',
401+ numericOrdering: true
402+ } )
403+
404+ The operation returns the following results:
405+
406+ .. code-block:: javascript
407+ :emphasize-lines: 2-3,7-8
408+ :copyable: false
337409
410+ [
411+ { n: '-2.1' },
412+ { n: '-10' },
413+ { n: '1' },
414+ { n: '2' },
415+ { n: '2.1' },
416+ { n: '2.2' },
417+ { n: '2.10' },
418+ { n: '2.20' },
419+ { n: '10' },
420+ { n: '20' },
421+ { n: '20.1' }
422+ ]
423+
424+
425+
426+ - ``numericOrdering: true`` sorts the string values in ascending
427+ order as if they were numeric values.
428+ - The two negative values ``-2.1`` and ``-10`` are not sorted in the
429+ expected sort order because they have unsupported ``-`` characters.
430+ - The value ``2.2`` is sorted before the value ``2.10``, due to the fact
431+ that the ``numericOrdering`` parameter does not support decimal
432+ values.
433+ - As a result, ``2.2`` and ``2.10`` are sorted in lexicographic order.
338434
339435.. toctree::
340436 :titlesonly:
0 commit comments