Since 2012 there's been a library natsort. It includes amazing functions such as natsorted and humansorted. More importantly, they work not only with lists!. Code:
from natsort import natsorted, humansorted
lst = [u"a", u"z", u"ą"]
dct = {"ą": 1, "ż": 3, "Ż": 4, "b": 5}
lst_natsorted = natsorted(lst)
lst_humansorted = humansorted(lst)
dct_natsorted = dict(natsorted(dct.items()))
dct_humansorted = dict(humansorted(dct.items()))
print("List natsorted: ", lst_natsorted)
print("List humansorted: ", lst_humansorted, "\n")
print("Dictionary natsorted: ", dct_natsorted)
print("Dictionary humansorted: ", dct_humansorted)
Output:
List natsorted: ['a', 'ą', 'z']
List humansorted: ['a', 'ą', 'z']
Dictionary natsorted: {'Ż': 4, 'ą': 1, 'b': 5, 'ż': 3}
Dictionary humansorted: {'ą': 1, 'b': 5, 'ż': 3, 'Ż': 4}
As you can see results differ when sorting dictionaries but considering given list both results are correct.
By the way, this library is also great to sort strings containing numbers:
from natsort import natsorted, humansorted
lst_mixed = ["a9", "a10", "a1", "c4", "c40", "c5"]
mixed_sorted = sorted(lst_mixed)
mixed_natsorted = natsorted(lst_mixed)
mixed_humansorted = humansorted(lst_mixed)
Output:
List with mixed strings sorted: ['a1', 'a10', 'a9', 'c4', 'c40', 'c5']
List with mixed strings natsorted: ['a1', 'a9', 'a10', 'c4', 'c5', 'c40']
List with mixed strings humansorted: ['a1', 'a9', 'a10', 'c4', 'c5', 'c40']