In mathematics, the lexicographic or lexicographical order, (also known
as dictionary order, alphabetic order or lexicographic(al) product), is
a natural order structure of the Cartesian product of two ordered sets.
Given two partially ordered sets A and B, the lexicographical order on
the Cartesian product A × B is defined as (a,b) ¿ (ä,b¿) if and only if
a < ä or (a = ä and b ¿ b¿). The result is a partial order. If A
and B are totally ordered, then the result is a total order also. More
generally, one can define the lexicographic order on the Cartesian
product of n ordered sets, on the Cartesian product of a countably
infinite family of ordered sets, and on the union of such sets.