def sort_none_last(key):
    """
    Given sort key function, returns new key function which can handle None.

    None values are sorted after non-None values.
    """
    return lambda x: (key(x) is None, key(x))