NumericalSort

NumericalSort[list]

sorts the elements of list into numerical order.

Details

Examples

open allclose all

Basic Examples  (2)

Sort by numerical value:

This may be different from the canonical expression order:

Groups of elements that can be compared with each other will typically be together in the result:

Scope  (7)

- comes before any real-valued expression, and comes after any real-valued expression:

Sort arguments of any expression:

Sort associations by numerical value:

Sort expressions of the same head by numerical value:

Complex-value expressions are sorted first by the real part and then by the absolute value of the imaginary part:

Sort quantities having compatible units:

If incompatible units are found, compatible units are grouped together:

Sort date objects:

Properties & Relations  (1)

NumericalSort uses NumericalOrder as ordering function:

Using Less as ordering function also sorts numeric expressions, but not necessarily other expressions:

Possible Issues  (1)

NumericalSort will not guarantee a particular ordering for different representations of the same number:

The canonical order will always rearrange in a definite way:

Introduced in 2017
 (11.1)