Is there a Google Sheets script that would be able to transpose my data, then sort it, then transpose it back. I need to do this formula below - but as a script.
=transpose(sort(transpose(J1:N4),1,))
My intention is to be able to sort my header columns A->Z so I can have a consistent placement of header columns every time I put them in. For example, sometimes the data comes as column A:G but the next time, the headers that used to be A:G are now AGBFCDE (scrambled). Sorting the entire columns going down is pretty strait forward but I need to sort A1:G1 while keeping the data below it still associated with the proper column header. For example, it would be "move entire column left or right" until the column headers are sorted A->Z. I am hoping this method of transposing-sorting-transposing back will do the trick but other recommendations would be welcome.
column 1 column4 column5 column 2 column 3
data 1 data 4 data 5 data 2 data 3
data 1 data 4 data 5 data 2 data 3
data 1 data 4 data 5 data 2 data 3
So as you can see above, the column headers are not in order. Every time I put them in, they will not be but I would like to know if there is preferably a script or some way to then sort Column 1:Column 5 in order even though they will never be pasted that way. If there is a better way besides transposing/sorting then I would be open to any method.