What I have is a list of dict:
x = [{25: 16}, {40: 32}, {11: 50}]
What i am trying is to sort it by value and get the top n elements:
where n = 2
what i did:
sorted_lst = x.sort(key=lambda d: d.values)
print(sorted_lst)
filtered = sorted_lst[:n]
but this did not work.
the output that I am trying to get is:
[{11: 50}, {40: 32}]