How to auto-sort Google Sheets by date (newest first), including Google Forms responses
Google Sheets cannot keep rows in date order by itself. Data > Sort range sorts once, and new rows (typed in, or sent by a Google Form) land at the bottom. This page gives a free Apps Script that re-sorts by a date column on every edit and every form response, plus a no-script formula option. Checked against Google's documentation on 1 November 2026.
1. Check that your dates are real dates
Most "sort by date doesn't work" problems are dates stored as text: they sort like words (10/2 before 9/30). In an empty column type =ISNUMBER(A2) (use your date column) and fill it down. Sheets stores real dates as numbers, so every row should say TRUE.
- A
FALSErow is text. Fix it with=DATEVALUE(A2)in a helper column, format it with Format > Number > Date, then copy it and use Edit > Paste special > Values only over the original column. DATEVALUEreads dates in the spreadsheet's locale (File > Settings > Locale): with a US locale01/02/2026is 2 January, with a UK one it is 1 February. Set the locale first.- The Timestamp column that Google Forms writes is already a real date and time.
2. The free script: sort by date on every edit
- Open the sheet, choose Extensions > Apps Script, delete what is in
Code.gsand paste this. - Set the tab name and the date column (A = 1, B = 2, ...). For a form, the tab is usually
Form Responses 1and the Timestamp is column 1. - Click Save.
onEditis a simple trigger: it runs on its own whenever a person edits the tab.
// Keeps one tab sorted by a date column, newest first.
const SHEET_NAME = 'Sheet1'; // for a form: 'Form Responses 1'
const DATE_COLUMN = 1; // A = 1 (a form's Timestamp is column 1)
const NEWEST_FIRST = true; // false = oldest first
const HEADER_ROWS = 1; // rows at the top that never move
function onEdit(e) {
const sheet = e.range.getSheet();
if (sheet.getName() !== SHEET_NAME) return;
sortByDate_(sheet);
}
function sortByDate_(sheet) {
const rows = sheet.getLastRow() - HEADER_ROWS;
if (rows < 2) return;
sheet.getRange(HEADER_ROWS + 1, 1, rows, sheet.getLastColumn())
.sort({column: DATE_COLUMN, ascending: !NEWEST_FIRST});
}
Rows with an empty date cell go to the bottom in both directions, so a half-typed row waits there until you fill in its date.
3. Google Forms: newest response on top
A form response is not an edit, so onEdit never sees it. Paste these two functions under the script, pick installFormTrigger in the toolbar, click Run once and allow access when Google asks. From then on each new response is sorted to the top.
function sortAfterForm() {
sortByDate_(SpreadsheetApp.getActive().getSheetByName(SHEET_NAME));
}
function installFormTrigger() {
ScriptApp.newTrigger('sortAfterForm')
.forSpreadsheet(SpreadsheetApp.getActive())
.onFormSubmit()
.create();
}
Run installFormTrigger only once: each run adds another trigger (see them under the clock icon, Triggers, in the Apps Script editor). Try it on a copy of the sheet first.
4. No script: a sorted copy with SORT()
If you would rather not touch the response tab at all, add a new tab, copy the header row into row 1 and put this in A2:
=SORT('Form Responses 1'!A2:Z, 1, FALSE)
It always shows the newest response first, but it is a read-only copy: you cannot type notes next to a row there (they would not move when the rows do), and columns you add to the response tab need the range widened.
5. The catches
- Only people and form submissions trigger it. Rows written by another script, the Sheets API, Zapier or Make fire no trigger, so they stay at the bottom until the next edit. The multiple-columns guide has a timer version for that.
- Text dates (step 1) sort as words, before or after all real dates.
- One block per tab: everything below the header is sorted as one range, and merged cells make the sort fail.
- Rows move while people work: someone editing row 5 can see it jump to row 2. Sorting newest first keeps new rows near the top, where people look anyway.
6. No code: KeepSorted
KeepSorted is an add-on that does this from a sidebar: choose the area and the date column, newest or oldest first, and it keeps the real rows sorted, header on top, blanks last, formatting and formulas moving with their rows. Free: one sorted area per tab with up to 2 sort columns (for example date, then name), sorted when people who have the add-on edit, no trial clock. Pro ($5/month or $39/year): sorting after Google Forms responses and edits by people who don't have the add-on, several tables per tab, up to 5 sort columns and custom orders.
KeepSorted is built and in testing. It is not in the Google Workspace Marketplace yet. Leave your email and we send one message when you can install it.
The scripts on this page stay free either way.
More KeepSorted guides
- Auto sort script generator
- Auto-sort alphabetically (A to Z)
- Auto-sort when a new row is added
- Auto-sort by multiple columns, when data changes
- StaySorted alternative: an honest comparison
Sources
- Apps Script: simple triggers (onEdit; script and API changes do not fire triggers)
- Apps Script: installable triggers (onFormSubmit)
- Range.sort reference
- DATEVALUE function · SORT function