0

Sorting lists numerically

how can I sort a list that contains both strings and integers in numeric descending order in python?

2nd Jul 2018, 5:22 PM
David Gedalia Ordman
David Gedalia Ordman - avatar
1 ответ
+ 4
Check it out: a = [1, 8, 'f', 'a', 9, '5'] print(sorted(a, key=str)[::-1]) >>> ['f', 'a', 9, 8, '5', 1]
2nd Jul 2018, 7:33 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar