Jan-25-2022, 07:13 PM
(Jan-25-2022, 07:06 PM)deanhystad Wrote: Because you are sorting the values, not the items.
dt = {'Finley' : 10, 'Evie' : 0, 'P1' : 0, 'P2' : 5, 'P1' : 0, 'P2' : 5, 'Finley' : 15, 'Evie' : 5} sorted_dt = sorted(dt.items(), key=lambda x: (int(x[1]), x[0])) print(sorted_dt)And of course now that this is a dictionary you cannot have duplicate names (keys).
Output:[('P1', 0), ('Evie', 5), ('P2', 5), ('Finley', 15)]
But the original list was between [] not {}, of course i changed that because it would not take it.
It does not return duplicate but finley 10 is not, and obviously when filter it return the latters.
ok
TY