I have the following list in Python upto n:
l = [[x_1,y_1,h_1,w_1], [x_2,y_2,h_2,w_2], ..., [x_n,y_n,h_n,w_n]]
And I need to sort it in descending order with respect to the sum of first and third elements in the sublists (x_i and h_i) and then get first n sublists.
I managed to do it by storing the sums in a new list, but is there an efficient way to sort it without creating the one?
EDIT: Sorry, this is a duplicate question indeed.