对字典进行排序_其他


sorted(字典名.items(), key=lambda x: x[1])

 

x = a[a['列名'] == 值]['列名']
y = a[a['列名'] == 值]['列名']

dic_xy = dict(zip(x,y))
lst_xy = sorted(dic_xy.items(), key=lambda x: x[1],reverse = True)
print(lst_xy)
dic = {}
for index in range(10):
    dic[lst_xy[index][0]] = lst_xy[index][1]
print(dic)