alist = [ ("b", 2), ("z", 5), ("a", 5), ("c", 4) ]alist = sorted(alist, key=lambda x: (-x[1], x[0]))print(alist)
Standard input is empty
[('a', 5), ('z', 5), ('c', 4), ('b', 2)]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!