sorting - Sort sublists in a list, Python -


i have 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 need sort in descending order respect sum of first , third elements in sublists (x_i , h_i) , first n sublists.

i managed storing sums in new list, there efficient way sort without creating one?

edit: sorry, duplicate question indeed.

go below link , see full detail how sort in python

sorting in python

 = sorted(l, key=lambda x: x[0] + x[2]) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -