Suppose that we have given 1D array C with permutation
and we want to permute rows and colums of 2D array A so that what was row k becomes row C[k]
and what was column C[k] becomes column k
This is part of algorithm presented in the Knuth's book
Extra 2D array not allowed only auxiliary 1D array is accepted