def tf2tidx(term_d):
    """ tf2tidx(): is getting a Term-Frequency dictionary and returns one
        with terms-index number. The index number is just their position in the
        descending order sorted list of dictionary keys. """

    # Get the TF list
    tf_l = term_d.items()
    # Short by Frequency Max frequency goes first (Descending Order)
    tf_l = sorted(tf_l, key=lambda tf_l: tf_l[1], reverse=True)

    # Create the Terms-Index Dictionary
    terms_l = [tf[0] for tf in tf_l]
    idx = range(len(terms_l))
    term_idx_d = dict(zip(terms_l, idx))

    return term_idx_d