Order[expr1, expr2] gives 1 if expr1 is before expr2 in canonical order, and -1 if expr1 is after expr2 in canonical order. It gives 0 if expr1 is identical to expr2.
In[1]:={Order[a, a], Order[a, b], Order[b, a]} Out[1]={0, 1, -1}
Protected
OrderedQ | NumericalOrder | LexicographicOrder | AlphabeticOrder | Equal | SameQ | Sort | SortBy | Signature | Ordering
1216th most common (1 in 153000 symbols)
2009th most common (1 in 48600 symbols)
introduced in Version 1 (June 1988)