I have the following problem and I am not sure how to speed it up:
I construct a list element by element like so:
a[[i]]=Table[some_function[j,k],{j,1,3},{k,1,6}]
This results in a list a with three indices and I would like to reorder its indices as follows:
Table[a[[i,j,k]],{j,1,3},{k,1,6},{i,1,4}]
Notice that initially the first index in a was i and now it is moved to the last position.
What I do at the moment is traverse the list with Table and reorder it elements as above, but I am wondering if there is a faster way to do this.
If this was a simple matrix, the Transpose operation would do the trick but I have no idea what the Transpose equivalent can apply here!
P.S.: the values of the list do not matter, just the order of its elements I need changing.


a[[i]]anda[[i,j,k]]? – thorimur Mar 29 '21 at 23:22Transpose[a, {3, 1, 2}]? orFlatten[a, {{2}, {3}, {1}}]? – kglr Mar 29 '21 at 23:25Flattenis about 5 times faster than Transpose! Thank you so much! – lucian Mar 29 '21 at 23:34