Using similar logic you could do rotation of non square arrays, you'd just have to flip the x and y sizes of the second array.
I suppose you could do something clever to rotate an array in place, but I think it's much simpler to just save the rotation on something else and then copy it back to the original if needed.