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

    """comparator function based on "key" function
    """
    def key_cmp(a, b):
        return cmp(key(a), key(b))
    return key_cmp