def calculate_term_frequencies(tokens):
    """Given a series of `tokens`, produces a sorted list of tuples in the
    format of (term frequency, token).
    """

    frequency_dict = {}

    for token in tokens:

        frequency_dict.setdefault(token, 0)
        frequency_dict[token] += 1

    tf = []

    for token, count in frequency_dict.items():
        tf.append( (count, token) )

    return sorted(tf, reverse=True)