Question DSA-SORT-0063
HardWhat is the output of this code?
a = [("b", 2), ("a", 1), ("c", 2), ("d", 1)]
print([k for k, v in sorted(a, key=lambda t: t[1])], [k for k, v in sorted(a, key=lambda t: -t[1])])
- A.
['d', 'a', 'c', 'b'] ['b', 'c', 'a', 'd']
- B.
['a', 'b', 'c', 'd'] ['d', 'c', 'b', 'a']
- C.
Sign up free to see the answer and a step-by-step explanation.