dico = {'a':5,'b':3,'c':-6,'d':6}
sorted_item = sorted(dico.items(),key=lambda x:(-x[1],x[0]))
#按照第二个元素排序,value值,负号表示倒序
result:
[('d', 6), ('a', 5), ('b', 3), ('c', -6)]
dico = {'a':5,'b':3,'c':-6,'d':6}
sorted_item = sorted(dico.items(),key=lambda x:(-x[1],x[0]))
#按照第二个元素排序,value值,负号表示倒序
result:
[('d', 6), ('a', 5), ('b', 3), ('c', -6)]