def closest_prior_to_date(date_to_compare, dates):
    """ Returns the index of the closest element in the sorted sequence
        prior to the specified date
    """
    for date in dates:
        if date <= date_to_compare:
            closest_element = date
        else:
            break
    return dates.index(closest_element)
