gives True if the ei are in canonical order, and False otherwise.


  • OrderedQ[{e,e}] gives True.
  • By default, OrderedQ uses canonical order as described in the notes for Sort.
  • OrderedQ[list,p] uses the ordering function p to determine whether each pair of elements in list is in order.
  • The ordering function p applied to a pair of elements e1, e2 may return either 1, 0, -1 or True, False. The value of p[e1,e2] is interpreted as follows:
  • 1e1 comes before e2
    0e1 and e2 should be treated as identical
    -1e1 comes after e2
    Truee1 and e2 are in order
    Falsee1 and e2 are out of order


open allclose all

Basic Examples  (2)

Scope  (2)

OrderedQ works with any expression:

OrderedQ works with any head, not just List:

Generalizations & Extensions  (1)

Use Greater to test for ordering:

Applications  (2)

Find tuples that are in order:

Find which tuples are in order:

Properties & Relations  (3)

Sort by default sorts using OrderedQ:

For numbers, OrderedQ is effectively equivalent to LessEqual:

OrderedQ uses non-strict order by default:

Check for strict canonical order by adding UnsameQ to the ordering function:

Alternatively, check whether Order gives 1:

Possible Issues  (1)

OrderedQ by default works structurally, not by numerical value:

Introduced in 1988
Updated in 2017