I have a list of words:
['apple', 'zoo', 'chicken', 'needle', 'car', 'computer']
I also have a dictionary with keys and values:
{'zoo': 42, 'needle': 32, 'computer': 18, 'apple': 39, 'car': 11, 'chicken': 12}
The keys of my dictionary are all from the list of words. How can I sort the dictionary so that the order of its keys is the same as the order of the words in the list? So once sorted, my dictionary should look like this:
{'apple': 39, 'zoo': 42, 'chicken': 12, 'needle': 32, 'car': 11, 'computer': 18}
Thanks so much!
collections.OrderedDictcollections.OrderedDict.