The main part of user-defined lexical order rules is stored in an order table, which is the first 256 elements of the array. These elements specify the lexical order for each CHR$ from 0 to 255. The order number is stored in the upper byte of each element. For example, to assign lexical order number 0 to the letter "A", and lexical order 1 to the letter "B":
10 INTEGER A(0:256)
20 A(NUM("A"))=SHIFT(0,-8)
30 A(NUM("B"))=SHIFT(1,-8)
When "A" is compared to "B", it will be smaller, since 0 is smaller than 1. "A"<B" returns 1.
Any special cases (2-to-1, 1-to-2, ignore) are noted in the lower byte of each element, and if additional information is needed it is stored in a "Special Case" table that follows after the first 256 elements of the array.
The lower byte of each element in the order table may have a value from 0 to 255. The meaning of each value is given in the following table:
Value
Meaning
0
No special case
1
Ignore this character
64+index
2-to-1 translation might be needed on this character
128+index
Perform 1-to-2 translation
192-256
Sub-order number exists for this character
In the above table, "index" is a value from 0 to 63 and specifies an index into the special case table.