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


uses the ordering function p to determine whether each pair of elements ei, ei+1 is in order.


  • OrderedQ[{e,e}] gives True.
  • By default, OrderedQ uses canonical order as described in the notes for Sort. This is equivalent to specifying Order as the ordering function p. »
  • 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
  • If the ordering function p returns a value p[e1,e2] other than the preceding ones, then e1 and e2 are effectively treated as being in order. »


open allclose all

Basic Examples  (4)

Check if a list of numbers is ordered:

Check if a list of strings is ordered:

Check if numerical expressions are sorted by their structure:

Check if the numerical values are sorted:

Check if a list is ordered when only examining the second part of each element:

Scope  (8)

OrderedQ works with any expression:

OrderedQ works with any head, not just List:

Check whether the values of an association are in order:

Specify Greater as the ordering function:

Use GreaterEqual to allow repeated elements:

Use NumericalOrder to allow complex numbers and number-like expressions:

Sort according to the rules of a particular language with AlphabeticOrder:

Define a custom ordering function that puts symbols ahead of numbers:

Use a pure function ordering function:

Applications  (2)

Find tuples that are in order:

Find which tuples are in order:

Properties & Relations  (7)

OrderedQ[expr] is equivalent to OrderedQ[expr,Order]:

Comparisons are stopped as soon as it is determined that a pair is out of order:

For explicit numbers, OrderedQ is effectively equivalent to LessEqual:

For any association, OrderedQ[assoc,]==OrderedQ[Values[assoc],]:

OrderedQ[expr] gives True when Sort[expr]===expr:

Sort by default effectively sorts using OrderedQ:

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  (2)

OrderedQ by default works structurally, not by numerical value:

Numericize elements or use NumericalOrder to compare by numerical value:

Unrecognized values of the ordering function are interpreted as elements being in order:

Use TrueQ to interpret failed comparisons as being out of order:

Wolfram Research (1988), OrderedQ, Wolfram Language function, https://reference.wolfram.com/language/ref/OrderedQ.html (updated 2017).


Wolfram Research (1988), OrderedQ, Wolfram Language function, https://reference.wolfram.com/language/ref/OrderedQ.html (updated 2017).


Wolfram Language. 1988. "OrderedQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/OrderedQ.html.


Wolfram Language. (1988). OrderedQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/OrderedQ.html


@misc{reference.wolfram_2024_orderedq, author="Wolfram Research", title="{OrderedQ}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/OrderedQ.html}", note=[Accessed: 17-July-2024 ]}


@online{reference.wolfram_2024_orderedq, organization={Wolfram Research}, title={OrderedQ}, year={2017}, url={https://reference.wolfram.com/language/ref/OrderedQ.html}, note=[Accessed: 17-July-2024 ]}