7 views
Problem: I've got a list of tuples. I want to sort them depending two elements. Here is following example unsorted = [('a', 4, 2), ('a', 4, 3), ('a', 7, 2), ('a', 7, 3), ('b', 4, 2), ('b', 4, 3), ('b', 7, 2), ('b', 7, 3)] sorted = [('a', 4 ... a', 7, 3), ('b', 7, 3)] I know how to sort them on the second element: sorted(unsorted, key = lambda element : element[1]) But how to do that with two keys?
asked
6 days ago
Mashhoodch
9.6k points