def get_highest_distances(results, num):
    """
    Takes results from instance_distance_analysis.run_distance_analysis and a number of top
    results to return.
    Returns 3 lists.

    - Documents with the largest median male instance distance
    - Documents with the largest median female instance distance
    - Documents with the largest difference between median male & median female instance distances \
    each list contains tuples, where each tuple has a document and the median male/female/difference \
    instance distance

    :param results: dictionary of results from run_distance_analysis
    :param num: number of top distances to return
    :return: 3 lists of tuples.

    """

    male_medians = []
    female_medians = []
    difference_medians = []

    for document in list(results.keys()):
        male_medians.append((results[document]['male']['median'], document))
        female_medians.append((results[document]['female']['median'], document))
        difference_medians.append((results[document]['difference']['median'], document))

    male_top = sorted(male_medians, reverse=True)[0:num]
    female_top = sorted(female_medians, reverse=True)[0:num]
    diff_top = sorted(difference_medians)[0:num]

    return male_top, female_top, diff_top