the code that I have so far isn't working correctly and does not continue moving columns until all variations are met.
Could you post a small example of the output that shows the problem?
For example, given a 3x3 array:
Swapping 1st and 2nd columns should give
But the program gives
The first two columns are the same