human
Complete this python program:
def get_sorted_filediffs(filediffs, key=None):
assistant
#Here is the Python program you requested.

    """Sorts a list of filediffs.
    The list of filediffs will be sorted first by their base paths in
    ascending order.
    Within a base path, they\ll be sorted by base name (minus the extension)
    in ascending order.
    If two files have the same base path and base name, we\ll sort by the
    extension in descending order. This will make :file:`*.h` sort ahead of
    :file:`*.c`/:file:`*.cpp`, for example.
    If the list being passed in is actually not a list of FileDiffs, it
    must provide a callable ``key`` parameter that will return a FileDiff
    for the given entry in the list. This will only be called once per
    item.
    """
    def cmp_filediffs(x, y):
        if (x[0] != y[0]):
            return cmp(x[0], y[0])
        (x_file, x_ext) = os.path.splitext(x[1])
        (y_file, y_ext) = os.path.splitext(y[1])
        if (x_file == y_file):
            return cmp(y_ext, x_ext)
        else:
            return cmp(x_file, y_file)
    def make_key(filediff):
        if key:
            filediff = key(filediff)
        filename = filediff.dest_file
        i = filename.rfind(u'/')
        if (i == (-1)):
            return (u'', filename)
        else:
            return (filename[:i], filename[(i + 1):])
    return sorted(filediffs, cmp=cmp_filediffs, key=make_key)