python - Sorting a large number of tuples by the first element -


i have large number of tuples in format:

(count, (r, g, b))  

how go sorting them first element, count value?

you use sorted function, returns list, , itemgetter:

from operator import itemgetter lst = [(count, (r, g, b)), ...] sorted_lst = sorted(lst, key=itemgetter(0)) 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -