@total_ordering
class ReversedOrder:

    def __init__(self, value):
        self.value = value

def __eq__(self, other):
    return other.value == self.value

def __lt__(self, other):
    return other.value < self.value
How to write Python sort key functions for descending values