dict1 = {'b':0, 'c':4, 'a':2, 'a':1, 'f':0}
# 字典排序
dict2 = dict(sorted(dict1.items(), key = lambda asd:asd[0]))
# 字典每一项反转后变成二维元组
tuple1 = tuple(tuple(reversed(items)) for items in dict1.items())
# 二维元组转换成二维列表
list1 = list(list(items) for items in list(tuple1))
print(dict1)
print(dict2)
print(tuple1)
print(list1)
---
{'b': 0, 'c': 4, 'a': 1, 'f': 0}
{'a': 1, 'b': 0, 'c': 4, 'f': 0}
((0, 'b'), (4, 'c'), (1, 'a'), (0, 'f'))
[[0, 'b'], [4, 'c'], [1, 'a'], [0, 'f']]
单例模式:
https://www.jianshu.com/p/6a1690f0dd00