KeepSorted

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.

2. The free script: sort by date on every edit

  1. Open the sheet, choose Extensions > Apps Script, delete what is in Code.gs and paste this.
  2. Set the tab name and the date column (A = 1, B = 2, ...). For a form, the tab is usually Form Responses 1 and the Timestamp is column 1.
  3. Click Save. onEdit is 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

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.

You're on the list. We'll email you when KeepSorted is ready.

The scripts on this page stay free either way.

More KeepSorted guides

Sources