# Definition:Lexicographic Order

## Definition

Let $\struct {S_1, \preceq_1}$ and $\struct {S_2, \preceq_2}$ be ordered sets.

The lexicographic order on $S_1 \times S_2$ is the relation $\preccurlyeq$ defined on $S_1 \times S_2$ as:

$\tuple {x_1, x_2} \preccurlyeq \tuple {y_1, y_2} \iff \tuple {x_1 \prec_1 y_1} \lor \paren {x_1 = y_1 \land x_2 \preceq_2 y_2}$

### Tuples of Equal Length

Let $n \in \N_{>0}$.

Let $\left({S_1, \preceq_1}\right), \left({S_2, \preceq_2}\right), \ldots, \left({S_n, \preceq_n}\right)$ be ordered sets.

Let $\displaystyle S = \prod_{k \mathop = 1}^n S_k = S_1 \times S_2 \times \cdots \times S_n$ be the Cartesian product of $S_1$ to $S_n$.

The lexicographic order on $S$ is the relation $\preccurlyeq$ defined on $S$ as:

$\left({x_1, x_2, \ldots, x_n}\right) \preccurlyeq \left({y_1, y_2, \ldots, y_n}\right)$ if and only if:
$\exists k: 1 \le k \le n: \left({\forall j: 1 \le j < k: x_j = y_j}\right) \land \left({x_k \prec_k y_k}\right)$
or:
$\forall j: 1 \le j \le n: x_j = y_j$

### General Definition

Let $\left({S, \preceq}\right)$ be an ordered set.

For $n \in \N: n > 0$, we define $T_n$ as the set of all ordered $n$-tuples:

$\left({x_1, x_2, \ldots, x_n}\right)$

of elements $x_j \in S$.

Let $\displaystyle T = \bigcup_{n \mathop \ge 1} T_n$.

The lexicographic order on $T$ is the relation $\preccurlyeq$ defined on $T$ as:

$\left({x_1, x_2, \ldots, x_m}\right) \preccurlyeq \left({y_1, y_2, \ldots, y_n}\right)$ if and only if:
$\exists k: 1 \le k \le \min \left({m, n}\right): \left({\forall j: 1 \le j < k: x_j = y_j}\right) \land x_k \prec y_k$
or:
$m \le n$ and $\forall j: 1 \le j \le m: x_j = y_j$.

## Ordinals

The lexicographic order is a relation on ordered pairs of ordinals denoted $\operatorname{Le}$.

$\operatorname{Le}$ is the set of all ordered pairs $\left({\left({\alpha, \beta}\right), \left({\gamma, \delta}\right)}\right)$ such that:

$(1): \quad$ Each $\alpha, \beta, \gamma, \delta$ is a member of the ordinal class
$(2): \quad$ $\alpha \in \gamma$ or $\alpha = \gamma \land \beta \in \delta$

## Also known as

Lexicographic order can also be known as the more unwieldy lexicographical ordering.

Some sources refer to it as dictionary order.