[Solved] Processing dictionary keys in sorted order [closed]


The particular order you’ve mentioned is neither sorted alphabetically nor numerically (by month number).

In the dictionary you’ve constructed, the key is the name of the month, and value is the month number. So in order to sort the dictionary by month number i.e. by value (which is what I think you wanted?) you can do something like this

for month_name, month_num in sorted(dict.items() key = lambda x : x[1]):
    print(month_name, end=' ')

2

solved Processing dictionary keys in sorted order [closed]