Answers for "Sort a list of tuples by an item in Python"

0

Sort a list of tuples by an item in Python

lst = [("val1", 2), ("val1", 1)]
lst.sort()
print(lst)
# Output: [('val1', 1), ('val2', 2)]
Posted by: Guest on March-14-2022

Code answers related to "Sort a list of tuples by an item in Python"

Python Answers by Framework

Browse Popular Code Answers by Language