Python Forum
Writing a lambda function that sorts dictionary - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Writing a lambda function that sorts dictionary (/thread-32839.html)



Writing a lambda function that sorts dictionary - GJG - Mar-09-2021

Hi guys! :)

dict1 = {'c':3, 'a':5, 'f':7, 'e':4}
Was wandering how to sort this dictionary by highest value first using lambda function?

expected result:
dict2 = {'f':7, 'a':5, 'e':4, 'c':3}
Appreciate the help !


RE: Writing a lambda function that sorts dictionary - buran - Mar-09-2021

check https://stackoverflow.com/questions/613183/how-do-i-sort-a-dictionary-by-value