This problem turns out to be much more complicated than you might expect. For example, how should whitespace and punctuation characters be sorted? Do leading zeroes affect the sort order, and if so, how? Should decimal numbers be recognized? Will there be any accented letters, or other characters outside the 7-bit ASCII set? If so, you'll have to use a Collator for the non-numeric parts--but Collators do very strange things with punctuation characters.