def pareto_frontier(Xs, Ys, maxX = True, maxY = True): myList = sorted([[Xs[i], Ys[i]] for i in range(len(Xs))], reverse=maxX) p_front = [myList[0]] for pair in myList[1:]: if maxY: if pair[1] >= p_front[-1][1]: p_front.append(pair) else: if pair[1] <= p_front[-1][1]: p_front.append(pair) p_frontX = [pair[0] for pair in p_front] p_frontY = [pair[1] for pair in p_front] return p_frontX, p_frontY