def flip(fn, permutation=(1, 0)):
    """Flips argument order of function according to permutation."""
    def inner(*args, **kwargs):
        args = tuple(args[p] for p in permutation) + args[len(permutation):]
        return fn(*args, **kwargs)
    return inner