Sorting with non-ASCII characters

bearophile bearophileHUGS at lycos.com
Thu Sep 19 08:42:50 PDT 2013


Chris:

> How do I sort text so that non-ascii characters like "á" are 
> treated in the same way as "a"?

The correct solution is a well implemented, well updated and well 
debugged Unicode Collation Algorithm, as already answered.
But if an approximation is enough then you could translate to D 
this Python code that converts a Unicode string to ASCII, and use 
it through a  schwartzSort:

http://newsbruiser.tigris.org/source/browse/~checkout~/newsbruiser/nb/lib/AsciiDammit.py

(If you translate that function to D, you could also add it to 
Dub later.)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list