Definition: Lexicographic order and comparison

Lexicographic ordering means dictionary like ordering on types that have several elements in some defined sequence.

If the first element of a sequence `A`

is less than the first element of a sequence `B`

then `A`

is lexicographically less than `B`

. Likewise, if the first element of `A`

is greater than the first element of `B`

then `A`

is lexicographically greater than `B`

. If the first element of `A`

is equal to the first element of `B`

then the lexicographic order of `A`

and `B`

is determined by the lexicographic order of `A`

's sequence and `B`

's sequence with the first element removed from both sequences. An empty sequence is smaller than a non-empty sequence.

The lexicographic order is commonly used for strings, vector, matrix and color classes.