[python-nl] Fw: utf locale sorting

Wichert Akkerman wichert at wiggy.net
Wed Sep 16 15:53:49 CEST 2009


On 9/16/09 15:51 , Igor Mavrović - Maqui at IRB wrote:
> 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?

Wrap the keys in a zope.ucol instance should do the trick.

Wichert.


More information about the Python-nl mailing list