Can anyone help me with a code to change the order of a given matrix. For example given the following matrix:

$\displaystyle \begin{pmatrix}1&2&3&4\\5&6&7&8\end{pmatrix}$

I want the function to change the order to:

$\displaystyle \begin{pmatrix}3&4&1&2\\7&8&5&6\end{pmatrix}$

The matrix is basically being divided into frames. I guess you can find the number of frames by dividing the number of columns by number of rows. So for this matrix it would be 2 frames.

I can only manage to get the first frame.