Finally, I wrote a little script to use the comparison and sort the letters. It starts with the letters considered, scrambles them, and then uses the comparator to get them back in the same place. It also "scores" an arrangement by the sum of the offsets of each letter from its proper place.