Answers for "python get dict values sorted by key"

1

python get dictionary keys sorted by value

sorted(A, key=A.get)
Posted by: Guest on October-10-2020
0

sort a dictionary by value then key

d = {'apple': 2, 'banana': 3, 'almond':2 , 'beetroot': 3, 'peach': 4}
[v[0] for v in sorted(d.items(), key=lambda kv: (-kv[1], kv[0]))]
Posted by: Guest on March-06-2021

Code answers related to "python get dict values sorted by key"

Python Answers by Framework

Browse Popular Code Answers by Language