Sort list of dictionaries by key (case insensitive)

Stefan Behnel stefan_ml at
Wed Jan 13 13:35:14 CET 2010

Peter Otten, 13.01.2010 13:25:
> >>> items = "Atem Äther ähnlich anders".split()
> >>> print " ".join(sorted(items, key=lambda s: s.lower()))

If you can make sure that 's' is either always a byte string or always a 
unicode string (which is good programming practice anyway), an unbound 
method can simplify (and speed up) the above, e.g.

     sorted(items, key=unicode.lower)


More information about the Python-list mailing list