It's easy enough to test the ordering of various expressions, but just as the precedence table contains some surprises even for experienced users I'm wondering if the canonical ordering does too? It seems odd if this isn't spelled out clearly somewhere, yet I don't recall seeing such a list.
The documentation for
Order tantalizingly says:
Order uses canonical order as described in the notes for Sort.
Yet the documentation for
Sort is quite basic, as far as I can find, saying only:
- Sort by default orders integers, rational, and approximate real numbers by their numerical values.
- Sort orders complex numbers by their real parts, and in the event of a tie, by the absolute values of their imaginary parts.
- Sort orders symbols by their names, and in the event of a tie, by their contexts.
- Sort usually orders expressions by putting shorter ones first, and then comparing parts in a depth-first manner.
- Sort treats powers and products specially, ordering them to correspond to terms in a polynomial.
- Sort orders strings as in a dictionary, with uppercase versions of letters coming after lowercase ones. Sort places ordinary letters first, followed in order by script, Gothic, double-struck, Greek, and Hebrew. Mathematical operators appear in order of decreasing precedence.
This describes how
Sort treats certain classes of expressions but it doesn't describe the relative ordering of these classes or attempt in any way to be exhaustive.