DocumentationMathematicaThe Mathematica BookMathematica Reference GuideSome General Notations and Conventions
A.3.9 Ordering of Expressions
The canonical ordering of expressions used automatically with the attribute Orderless and in functions such as Sort satisfies the following rules:
Integers, rational and approximate real numbers are ordered by their numerical values.
Complex numbers are ordered by their real parts, and in the event of a tie, by the absolute values of their imaginary parts.
Symbols are ordered according to their names, and in the event of a tie, by their contexts.
Expressions are usually ordered by comparing their parts in a depth-first manner. Shorter expressions come first.
Powers and products are treated specially, and are ordered to correspond to terms in a polynomial.
Strings are ordered as they would be in a dictionary, with the upper-case versions of letters coming after lower-case ones. Ordinary letters appear first, followed in order by script, Gothic, double-struck, Greek and Hebrew. Mathematical operators appear in order of decreasing precedence.