a = {6:2,8:0,1:4,-5:6,99:11,4:22}
print( sorted(a.items()) ) #默认安照key排序的
print( sorted(a.items(),key=lambda x:x[1]) ) #按照value排序
print(a )
参考:
http://www.runoob.com/python/python-func-sorted.html
https://www.cnblogs.com/alex3714/articles/5740985.html
内置方法参考:
https://docs.python.org/3/library/functions.html?highlight=built#ascii