У меня есть этот ввод< /p>
Код: Выделить всё
smith 20
jones 15
jones 20
Код: Выделить всё
def comparator(a, b):
if a[1] > b[1]:
return -1
if a[0] < b[0]:
return -1
if (a[0] == b[0]) and (a[1] == b[1]):
return 0
return 1
Код: Выделить всё
sorted(data, key=cmp_to_key(comparator))
Код: Выделить всё
jones 20
jones 15
smith 20
Подробнее здесь: https://stackoverflow.com/questions/627 ... le-problem