How does Python sort a list of tuples?

后端 未结 5 1705
广开言路
广开言路 2020-12-08 18:33

Empirically, it seems that Python\'s default list sorter, when passed a list of tuples, will sort by the first element in each tuple. Is that correct? If not, what\'s the ri

5条回答
  •  [愿得一人]
    2020-12-08 18:46

    Check out "Devin Jeanpierre" answer to this question sort-a-dictionary-in-python-by-the-value where he says to use a tuple and shows how to sort by the second value

提交回复
热议问题