Sorting strings containing special characters (german 'Umlaute')

DierkErdmann at mail.com DierkErdmann at mail.com
Fri Mar 2 08:59:35 EST 2007


Hi !

I know that this topic has been discussed in the past, but I could not
find a working solution for my problem: sorting (lists of) strings
containing special characters like "ä", "ü",... (german umlaute).
Consider the following list:
l = ["Aber", "Beere", "Ärger"]

For sorting the letter "Ä" is supposed to be treated like "Ae",
therefore sorting this list should yield
l = ["Aber, "Ärger", "Beere"]

I know about the module locale and its method strcoll(string1,
string2), but currently this does not work correctly for me. Consider
     >>> locale.strcoll("Ärger", "Beere")
     1

Therefore "Ärger" ist sorted after "Beere", which is not correct IMO.
Can someone help?

Btw: I'm using WinXP (german) and
>>> locale.getdefaultlocale()
prints
   ('de_DE', 'cp1252')

TIA.

  Dierk




More information about the Python-list mailing list