How do you sort a dictionary by the frequency of its values in Python? For example, if I have a dictionary:
{'apples': 2, 'oranges': 5, 'bananas': 2, 'corn': 1, 'tangerines': 2, 'popsicles': 5}
How can I get it to return:
{'apples': 2, 'bananas': 2, 'tangerines': 2, 'oranges': 5, 'popsicles': 5, 'corn': 1}
EDIT: Upon closer inspection, the only answer currently given does not answer this question. The answer sorts the dictionary according to the "size" of the values and not the frequency with which the values occur. Also, the answer that is linked also does not answer this question. Like the only answer currently given, the question linked is about sorting dictionaries according to the size of the values, not the frequency with which the values occur