在python中对字典键进行排序

问题描述:

我有一个字典,其中每个键都引用一个int值.根据值将键分类到列表中的最佳方法是什么?

I have a dict where each key references an int value. What's the best way to sort the keys into a list depending on the values?

>>> mydict = {'a':1,'b':3,'c':2}
>>> sorted(mydict, key=lambda key: mydict[key])
['a', 'c', 'b']