Nico Grubert, 13.01.2010 16:18:
print sorted(items, key=lambda d: locale.strxfrm(d.get('title')))

-> [{'id': 2, 'title': 'The Storm'}, {'id': 4, 'title': 'The thunder'}, {'id': 3, 'title': 'the bible'}, {'id': 1, 'title': 'the \xc4hnlich'}]

The entry with the umlaut is the last item in but according to german umlaut rules it should be the first item in the result.
Do I have to set anything with the locale module?

http://wiki.python.org/moin/HowTo/Sorting#Topicstobecovered

Stefan
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to