Perl: the Markov chain saw | |
PerlMonks |
Re: Diacritic-Insensitive and Case-Insensitve Sortingby Willard B. Trophy (Hermit) |
on Jan 05, 2004 at 15:02 UTC ( [id://318859]=note: print w/replies, xml ) | Need Help?? |
If you use locale;, you'll get most of the way there. It doesn't exactly consider all accented versions of a character to be identical, but it does sort all versions of A before B. This might be good enough for you. It certainly got me 95% of the way when my job was sorting multilingual dictionaries. Using a code example from the perllocale pod, this is what I get as the collation order for my locale, en_CA:
Using locale is a bit slower than an unadorned sort, but it's far faster and has fewer pitfalls than rolling your own locale-emulation system. lc and uc do exactly what you'd expect under locale, too. --
In Section
Seekers of Perl Wisdom
|
|