Google Apps Script auto‑sorts spreadsheet sheets
Labnol explains how a short Apps Script function can reorder sheet tabs alphabetically, saving time for large workbooks.
By Felo News Desk · Published
Labnol published two guides on October 30, 2026, showing how Google Apps Script can be used to automate sheet‑tab sorting and outlining the broader ecosystem of Google add‑ons.
What happened
One guide provides a code snippet that, when added to a spreadsheet’s script editor, sorts all tabs alphanumerically. The function sortGoogleSheets accepts a Boolean ascending flag, builds a locale‑aware compare function, and then calls SpreadsheetApp.getActiveSpreadsheet().getSheets().sort(compareFn). After sorting, each sheet is moved to the first position so the final order matches the desired direction. The script finishes with SpreadsheetApp.flush() to apply changes.
What the reports add
Labnol’s first article focuses on the sorting script itself, describing the options for case‑insensitive, numeric‑aware comparison and how to open the script editor via Extensions > Apps Script. The second article places the script in the context of Google Workspace add‑ons, noting that add‑ons are built with Apps Script but differ from regular scripts because their code is hidden from end users and they operate only on the currently open document.
What was said
Labnol wrote, “The compareFn function compares two sheets and returns a value that indicates whether the first sheet should come before or after the second sheet.” The same outlet also explained, “Google add‑ons are like extensions for Chrome… the server side code is written in Google Apps Script which is similar to JavaScript but runs on the Google Cloud.”
How it came about
The need for automated sorting stems from large spreadsheets such as the Udemy‑course tracker mentioned in the first guide, which contains about 50 sheets named after programming languages and is currently ordered randomly. Labnol’s earlier coverage of Google’s Connected Apps Platform (Google opens Gemini and Search to third‑party apps via Connected Apps Platform) highlighted Google’s push to extend developer tools across its ecosystem, a trend that includes making Apps Script more accessible for custom automation.
Key facts
- Labnol released a script that sorts Google Sheets tabs alphabetically. (labnol.org)
- The script can sort in ascending or descending order based on a Boolean flag. (labnol.org)
- Google add‑ons are built with Apps Script but hide their source code from users. (labnol.org)
Sources
- [1] labnol.org
- [2] labnol.org










