from functools import cmp_to_key class Player: def __init__(self, name, score): self.name = name self.score = score def __repr__(self): return f'{self.name} -> {self.score}' @classmethod def comparator(cls, current, _next): if current.score < _next.score : return 1 elif current.score > _next.score: return -1 else: if current.name < _next.name: return -1 elif current.name > _next.name: return 1 else: return 0