I have a list of lists (there cannot be tuples, since I have to generate it dynamically), and it is structured as a list of lists of one int and one float. Thus:
[[1,1.0345],[2,5.098],[3,4.89],[2,5.97]]
I want it to be sorted, but I managed to get a built-in sort function to sort by the first element of the lists or do nothing, but I need to sort them by the second element of the list and I do not want to implement my own sort function. So, an example of what I want is:
[[1,1.0345],[3,4.89],[2,5.098],[2,5.97]]
Can someone tell me how to make one of the built-in sort functions for this?
python sorting list
user381261
source share