简体   繁体   English

通过内键python对字典排序

[英]sort a dictionary by inner key python

I have a 3 dimensional dictionary 我有一本三维字典

 d = ({k1:{k2:{k3:v}}}
       and many more such keys....)

Now, I want to sort this dictionary by k3? 现在,我想按k3对这本字典进行排序? What is the best way to do this? 做这个的最好方式是什么?

 sorted_keys = sorted(d.keys(),key=lambda x:d[x]['key2']['key3'])

将为您排序键...(因为字典按定义未排序)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM