Strings are sorted by lexicographical order (also known as alphabetical order).
Here an example with some German words:
Do you want to sort via alphabet?
Uppercase letters are smaller in their value as Lowercase letters.
Here an example with some German words:
Output:In [70]: sorted(random.sample(words, 10))
Out[70]:
['Bakterienzüchtung',
'Chrzowitz',
'Generalfragen',
'Latzrock',
'Prognosemodell',
'Reliefklischee',
'chaotisieren',
'dreireihig',
'erwünschtestes',
'kampfunfähigem']
In [71]: sorted(random.sample(words, 10))
Out[71]:
['Ablehnen',
'Attenschweiler',
'Bewahrheitung',
'Filzgarn',
'Rollin',
'Schneckengrün',
'Textilgürtelreifen',
'anpflanzender',
'herausgestrichenen',
'kostenschonendes']
words = ["Ca", "ca", "cA"] print(sotred(words))
Output:['Ca', 'cA', 'ca']
Python is "seeing" the chars as values and they are compared as valueswords = ['Ca', 'cA', 'ca'] chars_as_int = [tuple(ord(c) for c in word) for word in sorted(words)] print(chars_as_int)
Output:[(67, 97), (99, 65), (99, 97)]
Python sorts by first letter, then second letter, ...Do you want to sort via alphabet?
Uppercase letters are smaller in their value as Lowercase letters.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!