A stupid thing that got me cracking my head. I'm sure you'll laugh, but how do I sort a sheet without including the first row in the sort?
Here's my code:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test1");
spreadsheet.sort(4); // or spreadsheet.sort(4,false); or spreadsheet.sort(4,true);
This sorts by column D, but it also sorts the first row. Column D contains only text.
Funny thing is that if you sort a column which has just numbers/dates, it works and it indeed avoids sorting the first row.
So, how can I sort a column with text and avoid sorting the first row?
I know that I can set a range start at A2 until the last column but this seems "messy". Something like this
spreadsheet.getRange('A2:AI').sort({column: 4, ascending: true});
Thanks