# coding=utf-8 class Point: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return ‘({}, {})‘.format(self.x, self.y) points = [Point(9, 2), Point(1,5), Point(2, 7), Point(3, 8), Point(2, 5)] sorted_points = sorted( points, key = lambda point: (point.x,point.y)) print (‘ ‘.join(map(str, sorted_points)))
(1, 5) (2, 5) (2, 7) (3, 8) (9, 2)