Add useful helper permute function.