9951 explained code solutions for 126 technologies


pythonHow to order dict by keys


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

source dict to sort

.items()

returns list of dict key/value tuples

item[0]

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

dict(

converts list of key/value tuples back into dict