Trouble sorting lists (unicode/locale related?)

Erlend Fuglum news_nospam at fuglum.net
Sun Sep 21 09:19:48 EDT 2003


On Sun, 21 Sep 2003 14:10:16 +0200, Peter Otten <__peter__ at web.de>
wrote:

>Erlend Fuglum wrote:
>
>> Hi everyone,
>> 
>> I'm having some trouble sorting lists. I suspect this might have
>> something to do with locale settings and/or character
>> encoding/unicode.
>> (...)
>
>Try setting the appropriate locale first:
>
>import locale
>locale.setlocale(locale.LC_ALL, ("no", None))
>
>Then for a case-insensitive sort:
>
>wordlist.sort(locale.strcoll)
>
>should do (disclaimer: all untested).

Grrrrrreat, that did it! Thank you very much!

Erlend




More information about the Python-list mailing list