Вам необходимо написать функцию, которая оценивает «пригодность» точки.
def fitness(point):
'''
ranks a point by the total number of points,
minus the difference between the number of x and y points.
uses total number of points as a secondary rank
'''
num_points = sum(point)
xydiff = max(point) - min(point)
return num_points - xydiff, num_points
Вышеуказанная функция должна быть скорректирована в зависимости от того, как вы хотите взвесить точки.
>>> points = [(2,9), (9,3), (5,4), (6,4)]
>>> sorted(points, key=fitness, reverse=True)
[(6, 4), (5, 4), (9, 3), (2, 9)]
>>> max(points, key=fitness) # the most fit point
(6, 4)