[Tutor] Fw: utf locale sorting

Igor Mavrović - Maqui@IRB igor.mavrovic at irb.hr
Wed Sep 16 15:51:02 CEST 2009


Hi,

I know about the use of locale module:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, "hr_HR.UTF8")
>>> print sorted(words, key=locale.strxfrm)

but I have specific and complicated data structure (list of lists containing 
strings, tuples and dictionaries) due to LDAP search result data.
So I use the 'key' option to get to the neaded attributes, and can't use it 
for the locale setting. How can I sort this monster list by attribute values 
inside it, and still get the correct sorting order?

Anyone? Thanks in advance! 



More information about the Tutor mailing list