How long did you think about this before giving up? You got a list of sorted numbers because you are sorting the values(), not the items(). You would have noticed this if you tried printing dt.values(). Spend more time trying to answer these kind of questions yourself. Your programming skills will increase much faster if you fix your own problems. Debugging is a great teacher. It produces a deeper and wider understanding than somebody giving you the answer.
dt = {'Finley' : 10, 'Evie' : 0, 'P1' : 0, 'P2' : 5, 'P1' : 0, 'P2' : 5, 'Finley' : 15, 'Evie' : 5}
print(dt.values())
Output:
dict_values([15, 5, 0, 5])
Notice that the names (keys) are gone. The are not going to reappear when sorted.
You cannot sort a dictionary, but you can put the items in a list and sort them.
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)
Output:
[('P1', 0), ('Evie', 5), ('P2', 5), ('Finley', 15)]
And of course now that dt is a dictionary you cannot have duplicate names (keys). Duplicate keys are replaced, so the dt dictionary is:
dt = {'Finley': 15, 'Evie': 5, 'P1': 0, 'P2': 5}
Once you have a sorted list of items you can use them to construct a dictionary that is sorted.
dt = {'Finley' : 10, 'Evie' : 0, 'P1' : 0, 'P2' : 5, 'P1' : 0, 'P2' : 5, 'Finley' : 15, 'Evie' : 5}
sorted_dt_items = sorted(dt.items(), key=lambda x: (int(x[1]), x[0]))
sorted_dt = {key:value for key, value in sorted_dt_items}
print(sorted_dt)
Output:
{'P1': 0, 'Evie': 5, 'P2': 5, 'Finley': 15}