sorting a list

Matthias Huening mhuening at zedat.fu-berlin.de
Thu Apr 29 05:18:23 EDT 2004


For simple lists you don't of course need locale.strcoll(a[0], b[0]).
(I just copied the function from one of my scripts where I need to sort a 
list of lists.) Sorry.


>>> locale.setlocale(locale.LC_ALL,"")
'German_Germany.1252'
>>> a = ['A', 'D', 'Ü', 'F', 'a', 'f', 'ä']
>>> def sortDeutsch(a,b):
        return locale.strcoll(a, b)

>>> a.sort(sortDeutsch)
>>> a
['a', 'A', '\xe4', 'D', 'f', 'F', '\xdc']
>>> 


Matthias



More information about the Python-list mailing list