Python Practice › Tuple Programs › Program 61

Sort by each tuple's minimum

EasyTuple Programs · 61 of 70

Write a Python program to sort tuples by their minimum value.

Advertisement
Input
[(1, 5, 7), (3, 4, 2), (4, 9, 0)]
Output
[(4, 9, 0), (1, 5, 7), (3, 4, 2)]

Approach

  1. key=min.

Solution

Python
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.

More tuple programs

← All 70 Tuple Programs

Leave a Comment