A Dance of Many Dimensions Challenge
Given a n-dimensional array of integers and a permutation of the first n natural numbers, permute the array dimensions accordingly.
Details
This challenge is inspired by MATLABs permute. demonstration
The permutation is given as a list of integers, e.g. [1,3,2] means 1 gets mapped to 1, 2 gets mapped to 3 and 3 gets mapped to 2 (here the ith entry is the value i gets mapped to). But you can use other formats that are convenient, for instance as cycles or as a function. If it is more convenient you can also use 0-based indexing.
The array can be assumed to be a full &quot;rectangular&quot; m1 x m2 x ... x mn-array (i.e. you can assume it is not ragged/jagged).
You can assume that n is not too large, as many languages have a limit of the number of dimensions in a nested array.
If your language does not support multidimensional arrays, you can also take a string that represents the array as input.
Examples

Any n-dimensional array with the identity permutation [1,2,3,...,n] will be unchanged.
The array [[10,20,30],[40,50,60]] with the permutation [2,1] gets mapped to [[10,40],[20,50],[30,60]].
The array [[[1,2],[3,4]],[[5,6],[7,8]]] with the permutation [2,3,1] gets mapped to [[[1,3],[5,7]],[[2,4],[6,8]]].
Languages with built-in solutions

based on this proposal by xnor

APL (Dyalog Unicode), 1 byte



⍉


Try it online!

J, 2 bytes

|:


Try it online!

R, 5 bytes



aperm


Try it online!

Octave/MATLAB, 8 bytes



@permute


Try it online!

Wolfram Language (Mathematica), 9 bytes

Transpose


Try it online!

Julia, 11 bytes



permutedims


Try it online!