I have a google sheet that I would like to sort different ranges by the 2nd column in each range. Example:
A B C D E F G
p 7 1 h 9 1
q 6 2 j 3 2
g 9 3 p 7 3
I need the range A:C sorted by B and the range E:G sorted by F. When I write the script, only the first set of data sorts. Here is the script I have so far based on my current spreadsheet:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1")
var range = sheet.getRange("A3:C450");
// Sorts by the values in column 2 (B)
range.sort({column: 2, ascending: true});
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1")
var range = sheet.getRange("D3:F450");
// Sorts by the values in column 5 (E)
range.sort({column: 5, ascending: true});
}
}
How can I get it to run both of thse?