Lexicographic order (source code)

= Lexicographic order
{wiki}

= Lexicographic
{synonym}

For equal-size subsets $A$ and $B$ of an ordered ground set, $A$ precedes $B$ in lexicographic order when the smallest element of their symmetric difference belongs to $A$.

For finite <sequences> over a <total order>, <lexicographic order> compares the first differing <sequence terms>; the smaller term determines the smaller <sequence>. If one <sequence> is a proper prefix of the other, the shorter precedes its extension. For fixed-length <tuples>, this is the first-difference rule used by <radix sort key encoding>.