I can't figure out why my code doesn't work, I have a list(or dict, i tried both) of tuples, I'd like to order it by the second value of the tuple and in case 2 tuples have the same second values, by the first one. I tried this:
sorted(my_list, key=lambda k: (k[1], k[0]), reverse=True)
but what I get is a list sorted only by its second value...for example with this list:
l = [('ee',10), ('oo',11), ('aa', 10)]
I get this output: [('oo', 11), ('ee', 10), ('aa', 10)]
but lexicographically, 'aa' comes before 'ee'...
what am I doing wrong? I tried with my_list.sort() or with a dict but nothing.
the problem is probably the "reverse true" condition, but what I'm trying to get is this output: [('oo', 11), ('aa', 10), ('ee', 10)]
basically I want the reverse true applied only to the first condition of the lambda... it is possible?