I am using the following code to sort tabs alphabetically:
function sheetNames() { var ss = SpreadsheetApp.getActiveSpreadsheet(); // Store all the worksheets