按值排序,reverse=True为从大到小排序
dic = {'a':31, 'bc':5, 'c':3, 'asd':4, 'aa':74, 'd':0}dic= sorted(dic.iteritems(), key=lambda d:d[1], reverse = True)
按key排序
dic=sorted(dic.iteritems(),key=lambda d:d[0])
生成的结果为元组