from typing import OrderedDict


def count_occurrences(count_field,input_dict):
    """
    Count occurances of value from a dictionary.  Count field represents the dictionary key to look at.
    The return is a dictionary of unique values and how many times they show up.
    The dictionary key = unique value | dictionary value = number of times key occurs.
    """
    count = dict()
    for row in input_dict.keys():
        var = input_dict[row][count_field]
        if var not in count:
            count[var] = 1
        else:
            count[var] = count[var]+1
    #sort dictionary by count: largest -> Smallest
    count = OrderedDict(sorted(count.items(), key = lambda x: x[1], reverse=True))
    return count