This was kinda interesting because I was needing to write a script to do the exact same thing.
The script I wrote will change the formatting from a horizantal reading sort in a grid to a vertical sort in a grid, which isn't straightforward when the data is in a linear array.
A B C D
E F G...