I have a list of lists consisting of two numbers.
[[2, 3], [7, 8], [3, 5]]
I would like to sort them based on the division of each of them:
e.g. 2/3 (0.666), 7/8 (0.875) 3/5 (0.6) to output:
[[3, 5], [2, 3], [7, 8]]
I suppose that somehow I will use lambda, but I do not know how to write it correctly. Something like this, but it just sorted by values:
list_of_lists.sort(key=lambda x: (x[0],x[1]))
How to do arithmetic?
source share