Check out example codes for "google sheets script onedit sort for multiple sheets". It will help you in understanding the concepts better.

Code Example 1

function onEdit(event){
  	var ss = SpreadsheetApp.getActiveSpreadsheet();
  	var sheet = event.source.getActiveSheet().getName()
  	var editedCell = event.range.getSheet().getActiveCell();
	if(sheet=="Loan Inquiries"){
  		var columnToSortBy = 2;
  		var tableRange = "A3:T99"; //range to be sorted
  		if(editedCell.getColumn() == columnToSortBy){   
    		var range = ss.getActiveSheet().getRange(tableRange); 
    		range.sort( { column : columnToSortBy, ascending: true } );
  		}
    }
  	else if(sheet=="Deals in Escrow"){
    	var columnToSortBy = 7;
    	var tableRange = "A3:T99"; //range to be sorted
  		if(editedCell.getColumn() == columnToSortBy){   
     		var range = ss.getActiveSheet().getRange(tableRange); 
    		range.sort( { column : columnToSortBy, ascending: true } );
  		}
    }
  	else{return}
}

Learn ReactJs, React Native from akashmittal.com