Contents

Automatically Sort Data in Google Sheets

Contents

Automatically Sort Data in Google Sheets

Extension -> Apps script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
function autoSort(e) {
  const ss = SpreadsheetApp.getActiveSpreadsheet()
  const ws = ss.getSheetByName("Sheet1")
  const range = ws.getRange(2,1,ws.getLastRow()-1,2)
  range.sort({column: 2, ascending: false})
}

function onEdit(e){
  autoSort(e)
}