I have a dictionary and a list. The values of the keys match those of the list, I'm just trying to find out how to sort the values in the dictionary by the values in the list.
>>> l = [1, 2, 37, 32, 4, 3]
>>> d = {
32: 'Megumi',
1: 'Ai',
2: 'Risa',
3: 'Eri',
4: 'Sayumi',
37: 'Mai'
}
I've tried using something along the lines of...
>>> sorted(dict.keys(), key=list.index)
... but obviously that only returns the keys in the desired order.
(Should have realized at 3AM that list
and dict
were horrible names, I changed them to l
and d
accordingly.)