import collections


def _compute_pctls(measures):
    """Return 50pctl, 90pctl, 99pctl, and 999pctl in a dict for the given dissymetries."""
    # If measures is empty, then one of the diffables was empty and not the other,
    # so the dissymmetry pctls should all be set at 100%
    if not measures:
        return None

    pctls = collections.OrderedDict()

    sorted_measures = sorted(measures)
    for i in [50, 75, 90, 99, 99.9]:
        # Don't even try to interpolate.
        rank = int(i / 100. * (len(measures)))
        pctls[i] = sorted_measures[rank]

    return pctls