NumericalOrder

NumericalOrder[e1,e2]

gives 1 if e1<e2, -1 if e1>e2, 0 if e1 and e2 are identical or numerically the same and Order[e1,e2] if e1 and e2 are not numerically comparable.

Details

  • 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.

Examples

open allclose all

Basic Examples  (4)

These two numbers are not ordered:

In[1]:=
Click for copyable input
Out[1]=

These two are numerically the same:

In[2]:=
Click for copyable input
Out[2]=

Compare numeric expressions:

In[1]:=
Click for copyable input
Out[1]=

This is not always the same as the canonical order of expressions:

In[2]:=
Click for copyable input
Out[2]=

Compare quantities:

In[1]:=
Click for copyable input
Out[1]=

Compare dates:

In[1]:=
Click for copyable input
Out[1]=

Scope  (6)

Applications  (1)

Properties & Relations  (8)

Possible Issues  (1)

See Also

NumericalSort  Sort  Order  AlphabeticOrder  Less  Greater  Equal

Introduced in 2017
(11.1)