Possible Duplicate:
How do I sort a list of strings in Python?
How do I sort unicode strings alphabetically in Python?
I have a list of strings list
and want to sort it alphabetically. When I call list.sort()
the first part of the list contains the entries starting with upper case letters sorted alphabetically, the second part contains the sorted entries starting with a lower case letter. Like so:
Airplane
Boat
Car
Dog
apple
bicycle
cow
doctor
I googled for an answer but didn't came to a working algorithm. I read about the locale
module and the sort
parameters cmp
and key
. Often there was this lambda
in a row with sort
, which made things not better understandable for me.
How can I get from:
list = ['Dog', 'bicycle', 'cow', 'doctor', 'Car', 'Boat', 'apple', 'Airplane']
to:
Airplane
apple
bicycle
Boat
Car
cow
doctor
Dog
Characters of foreign languages should be taken into account (like ä, é, î).