0
Sorting lists numerically
how can I sort a list that contains both strings and integers in numeric descending order in python?
1 Réponse
+ 4
Check it out:
a = [1, 8, 'f', 'a', 9, '5']
print(sorted(a, key=str)[::-1])
>>>
['f', 'a', 9, 8, '5', 1]
how can I sort a list that contains both strings and integers in numeric descending order in python?