python - Sort nested dictionary by values -
i trying sort dictionary dictionary inside. how dict looks like:
{'pos2': {'stegano': 0, 'sum': 200, 'misc': 100, 'web': 0, 'ppc': 0, 'crypto': 0, 'admin': 0, 'vuln': 0, 'forensics': 0, 'hardware': 0, 'reverse': 0, 'recon': 100}, ...}
i want sort 'sum'
key stored in nested dict. have tried different solutions here sort nested dictionary value, , remainder value, in python , here sorting nested dictionary lists in python work fine on python 2.x doesn't work on python 3.x. give me advice how implement kind of sort ?
simply return desired sort key each item
sorted(inputdict.items(), key=lambda item: item[1]['sum'])
Comments
Post a Comment