Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 3 维字典
d = ({k1:{k2:{k3:v}}} and many more such keys....)
现在,我想按 k3 对这本字典进行排序?做这个的最好方式是什么?
sorted_keys = sorted(d.keys(),key=lambda x:d[x]['key2']['key3'])
将为您排序键......(因为字典根据定义是未排序的)