I tried your solution with a permutation table but didn't really work for me.
I did, however, had more success following this tutorial. Instead of using the width of the array as a measure, I made the variable choose between each value (Y coordinates) in that row.
The only issue is that the some parts are being shuffled on top of each other because, some of their, are being fed the same number (Y coordinate).
Is there a way for me to avoid this happening? Like with a variable that keeps checking if the number has been repeated?