Python Practice › Tuple Programs › Program 61
Sort by each tuple's minimum
Write a Python program to sort tuples by their minimum value.
Input
[(1, 5, 7), (3, 4, 2), (4, 9, 0)]
Output
[(4, 9, 0), (1, 5, 7), (3, 4, 2)]
Approach
key=min.
Solution
print(sorted([(1, 5, 7), (3, 4, 2), (4, 9, 0)], key=min))Output
[(4, 9, 0), (1, 5, 7), (3, 4, 2)]
Learn the concept
New to this topic? Read the lesson, then come back.