:param processor:
        a function to process the key returned by the supplied key function

    :param fn:
        a key function

    :return:
        a function that wraps around the supplied key function to further
        process the key before returning.

def process_key(processor, fn):
    """
    :param processor:
        a function to process the key returned by the supplied key function

    :param fn:
        a key function

    :return:
        a function that wraps around the supplied key function to further
        process the key before returning.
    """
    def f(*aa, **kw):
        k = fn(*aa, **kw)
        if isinstance(k, (tuple, list)):
            return (processor(k[0]),) + tuple(k[1:])
        else:
            return processor(k)
    return f