- NumericalOrder provides a general alternative to canonical order in which numeric expressions, dates and Quantity objects are treated by value, but it is otherwise equivalent to canonical order.
- Quantity expressions with compatible units are compared to each other by magnitude after converting them to a common unit.
- DateObject expressions are compared to each other by AbsoluteTime.
- TimeObject expressions are compared by AbsoluteTime.
- NumericalOrder compares inexact numbers using all available significant digits. Unlike Equal, it does not allow any extra tolerance.
- NumericalOrder can be used as an ordering function in functions like Sort, OrderedQ or Ordering.
Examplesopen allclose all
Basic Examples (4)
Use NumericalOrder as ordering function:
Properties & Relations (8)
For numeric expressions of different value, NumericalOrder compares them using those values:
Order always compares expressions structurally and may give different results:
For comparable expressions e1, e2 a result NumericalOrder[e1,e2]0 implies e1-e2==0:
NumericalOrder compares inexact numbers using all available significant digits:
NumericalOrder compares complex values by the real part and then by absolute value of the imaginary part:
This is consistent with Order for numbers:
Equivalent quantities have a NumericalOrder of 0:
Use Equal to show that they are indeed equivalent quantities:
Possible Issues (1)
Sorting with NumericalOrder will not guarantee a particular ordering for different representations of the same number:
Wolfram Research (2017), NumericalOrder, Wolfram Language function, https://reference.wolfram.com/language/ref/NumericalOrder.html.
Wolfram Language. 2017. "NumericalOrder." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumericalOrder.html.
Wolfram Language. (2017). NumericalOrder. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumericalOrder.html