human
Complete this python program:
def key_ordering(cls):
assistant
#Here is the Python code you requested.

    """Decorates a class with extra methods that implement rich comparison
    operations and ``__hash__``.  The decorator assumes that the class
    implements a function called ``_cmp_key()``.  The rich comparison
    operations will compare objects using this key, and the ``__hash__``
    function will return the hash of this key.
    If a class already has ``__eq__``, ``__ne__``, ``__lt__``, ``__le__``,
    ``__gt__``, or ``__ge__`` defined, this decorator will overwrite them.
    Raises:
    TypeError: If the class does not have a ``_cmp_key`` method
    """
    def setter(name, value):
        value.__name__ = name
        setattr(cls, name, value)
    if (not has_method(cls, '_cmp_key')):
        raise TypeError(("'%s'    doesn't    define    _cmp_key()." % cls.__name__))
    setter('__eq__', (lambda s, o: ((s is o) or ((o is not None) and (s._cmp_key() == o._cmp_key())))))
    setter('__lt__', (lambda s, o: ((o is not None) and (s._cmp_key() < o._cmp_key()))))
    setter('__le__', (lambda s, o: ((o is not None) and (s._cmp_key() <= o._cmp_key()))))
    setter('__ne__', (lambda s, o: ((s is not o) and ((o is None) or (s._cmp_key() != o._cmp_key())))))
    setter('__gt__', (lambda s, o: ((o is None) or (s._cmp_key() > o._cmp_key()))))
    setter('__ge__', (lambda s, o: ((o is None) or (s._cmp_key() >= o._cmp_key()))))
    setter('__hash__', (lambda self: hash(self._cmp_key())))
    return cls