Most programmers know how to compare strings with the
compareTo method of the
String class. The value of
a.compareTo(b) is a negative number if
a is lexicographically less than
b, zero if they are identical, and positive otherwise.
Unfortunately, this method is useless unless all your words are in uppercase ASCII characters. The problem is that the
compareTo method in the Java programming language uses the values of the Unicode character to determine the ordering. For example, lowercase characters have a higher Unicode value than uppercase characters, and accented characters have even higher values. This leads to absurd results; for example, the following five strings are ordered according to the
America Zulu ...