From a scrambled grid reconstitute the solved grid in order to do that slide lines and columns (it's a puzzle : give it a try and if you are stuck, you can look at CARYKH's video in description)
This is my scratch implementation of CARYKH's 2D Rubik's Cube game : his video -> https://youtu.be/95rtiz-V2zM his YouTube chanel -> https://www.youtube.com/channel/UC9z7EZAbkphEMg0SP7rw44A