The dictionary is sorted by key and value

python dictionary sorting problem

 #value排序
    dict1=sorted(dict1.items(),key=lambda x:x[1],reverse=True)
 #key排序
  dict1=sorted(dict1.items(),key=lambda x:x[0],reverse=True)

Guess you like

Origin blog.csdn.net/kairui_guxiaobai/article/details/105245604