d = {‘a‘:1,‘b‘:4,‘c‘:2}
方法一:
sorted(d.items(),key = lambda x:x[1],reverse = True)
方法二:
import operator sorted(d.items(),key = operator.itemgetter(1))
原文地址:https://www.cnblogs.com/students/p/9396151.html
时间: 2024-10-10 16:17:07
d = {‘a‘:1,‘b‘:4,‘c‘:2}
方法一:
sorted(d.items(),key = lambda x:x[1],reverse = True)
方法二:
import operator sorted(d.items(),key = operator.itemgetter(1))
原文地址:https://www.cnblogs.com/students/p/9396151.html