If you will accept ONLY an exact rearrangement of the columns, then we might look for a permutation matrix. Does one exist?
PAB = (normalize(A,1,'norm',2)'*normalize(B,1,'norm',2)) > 1-10*eps
If the matrix PAB is a valid permutation matrix, then it will have exactly one unit element in every row and every column. Now we can transform B using the product:
If you feel you really need to get the permutation vector itself, I could do this:
PAC = (normalize(A,1,'norm',2)'*normalize(C,1,'norm',2)) > 1-10*eps
Now, suppose we have a matrix that fails to have an exact rearrangeent of the columns?
PAD = (normalize(A,1,'norm',2)'*normalize(D,1,'norm',2)) > 1-10*eps
No such permutation of the columns exists here. A simple test of that is:
Both such tests should result in vectors of purely ones if PAD were a permutation matrix.