from functools import total_ordering @total_ordering class Person: def __init__(self, first, last): self.first_name, self.last_name = first, last def __eq__(self, other): return (self.first_name, self.last_name) == (other.first_name, other.last_name) def __lt__(self, other): if self.last_name < other.last_name: return True elif other.last_name < self.last_name: return False elif self.first_name < other.first_name: return True else: return False