In Industry class: def __lt__(self, other): if not isinstance(other, Industry): return None # Cannot compare return self.id < other.id def __eq__(self, other): if not isinstance(other, Industry): return None # Cannot compare return self.id == other.id