I was trying to make my google sheets document automatically sort on date (ascending). When I run the code by myself, it works but the onEdit function which would make it automatic, doesn't work.
I followed this Youtube video and changed the values to my document: https://www.youtube.com/watch?v=3EUI_PgxarA . A couple of days ago the onEdit function did work and there have been no further changes since.
This is my code:
function autoSort(){
  const ss = SpreadsheetApp.getActiveSpreadsheet()
  const ws = ss.getSheetByName("Toekomstplanning")
  const range = ws.getRange(5,1,ws.getLastRow()-1,6)
  range.sort({column: 6, ascending: true})
}
function onEdit(e){
  const row = e.range.getRow()
  const column = e.range.getColumn()
  if(!(column === 6 && row >= 5)) return 
  autoSort()
}
 
     
     
    