9951 explained code solutions for 126 technologies


pythonHow to order dict by values


sorted = dict(sorted(unsorted.items(), key=lambda item: item[1]))ctrl + c
unsorted

source dict to sort

.items()

returns list of dict key/value tuples

item[1]

key to sort given list by (values in our case)

dict(

converts list of key/value tuples back into dict