def nondominated_cmp(p, q):
    """
    From the 'front_number' the smaller value is favourized.
    From the 'crowding_distance' the higher values are favoured.
    :param p: Individual
    :param q: Individual
    :return: -1 if x dominates
              0 if they are equals
              1 if y dominates
    """
    if p.features['front_number'] == q.features['front_number']:
        if -p.features['crowding_distance'] < -q.features['crowding_distance']:
            return -1
        elif -p.features['crowding_distance'] > -q.features['crowding_distance'
            ]:
            return 1
        else:
            return 0
    elif p.features['front_number'] < q.features['front_number']:
        return -1
    elif p.features['front_number'] > q.features['front_number']:
        return 1
    else:
        return 0
