#解决方案:使用内置函数sorted 1.利用字典数据转化元组2.传递sorted函数的key参数
#1.利用字典数据转化元组
from random import randint
d = {x: randint(60,100) for x in 'xyzabc'}
for each in zip(d.values(),d.keys()):
q = print(each) # -> (79, 'x')(94, 'y')(74, 'z')(62, 'a')(62, 'b')(76, 'c')
k = sorted(zip(d.values(),d.keys()))
print(k) #-->[(62, 'a'), (62, 'b'), (74, 'z'), (76, 'c'), (79, 'x'), (94, 'y')]
#2.传递sorted函数的key参数
g = sorted(d.items(),key = lambda x: x[1])
print(g)