+ 1
Sort list of lists in Py
I'm working in a analysis project, I have a list like this, a = [ ["hi", 15], ["Hello", 20], ["Hey", 10] ] I need to sort this list under the second element of the list, Like this, a = [ ["Hello", 20], ["hi", 15], ["Hey", 10] ] The list need to be sorted under those numbers. So far I tried, a = sorted(a[1]) It didn't worked in the way I expected. Give me a solution please.
1 ответ
+ 3
a.sort(key=lambda x: int(x[1]))