Computing 'score' of string which preserves < relation
Suppose that your alphabet has size $N$ (say, $N=256$). You can think of each word as being over an alphabet of size $N+1$, with the extra element (first in the order) representing "end of word". Take a short prefix of the word (of some fixed constant size) and think of it as the base $N+1$ representation of a natural number.

As an example, suppose that the alphabet is $A&lt;B$ (in this order), and that we take prefixes of length 2. Consider the strings
$$
A &lt; AA &lt; AAA &lt; B.
$$
We think of these as the numbers $1,11,111,2$ in base 3. Taking prefixes of length 2, we get $10,11,11,20$ (here you see how the extra element is used). The encodings are thus
$$
3 &lt; 4 = 4 &lt; 6.
$$