Source Code:
(back to article)
from operator import itemgetter my_list = [(1, 3), (4, 2), (3, 1)] sorted_list = sorted(my_list, key=itemgetter(1)) print(sorted_list) # [(3, 1), (4, 2), (1, 3)]
Result:
Report an issue