How to automatically sort Google Form responses

I use Google Forms a lot and I love the product. However, one frustrating thing is that every time the form receives a new response, I have to scroll down to the bottom of the form's response spreadsheet to see it. I would much rather have new responses at the top of the spreadsheet so I immediately see them when I open the spreadsheet.

In this tutorial, I'll show you how to automatically sort your Google Form's responses so you'll always see the most recent ones at the top. This has saved me so much time over the past few months! If your form receives a lot of responses, it can be pretty painful to scroll through and find the new responses each time so I hope you find this tutorial helpful.

Step 1 — Open the spreadsheet that is collecting the responses from your form

For this tutorial, I created a test form with just two questions. The form asks users to enter their name and favorite color.

Screenshot of a Google Form containing two questions.

I submitted 10 responses one after another and they were saved to the form's spreadsheet in the order that I submitted them. What we want to achieve in this tutorial is for these responses to be sorted such that the most recent responses are at the top of the spreadsheet.

Screenshot of a spreadsheet showing the form's responses.

Step 2 — Create a Google Apps Script to sort the sheet by the Timestamp column in descending order

Open the script editor by selecting Extensions —> Apps Script from the menu. In the script editor, replace the myFunction function with the code below and save the script by selecting File —> Save from the editor's menu (or by pressing CTRL + S on your keyboard).

Replace the code in the script editor with the code below.

/** @OnlyCurrentDoc */
function sortResponses() {
  var sheet = SpreadsheetApp.getActive().getSheetByName("Form Responses 1");
  sheet.sort(1, false);
}

Save your script and try running it. Once the script finishes running, your spreadsheet should be sorted such that the most recent responses are at the top.

Screenshot of the form's response spreadsheet. The responses are sorted by timestamp in descending order.

How does the sortResponses() function work?

/** @OnlyCurrentDoc */
function sortResponses() {
  var sheet = SpreadsheetApp.getActive().getSheetByName("Form Responses 1");
  sheet.sort(1, false);
}

The script is very simple.

  • First, it gets the sheet containing your form's responses. The script assumes that this sheet is called "Form Responses 1", which is the default name generated by Google Forms. If you change this name in your spreadsheet, make sure you also update the script.

  • Next, it sorts the sheet by the first column in descending order. The script assumes that the first column contains the timestamps of the responses. The second parameter of the sort() function specifies the sort order. Setting it to false will sort in descending order (if you set it to true, your spreadsheet will be sorted by timestamp in ascending order).

Step 3 — Create a Form Submit trigger to automatically run the sortResponses() function whenever your form is submitted

Now that you have successfully tested your script, the next step is to have it run automatically whenever your form is submitted. To do this, you'll need to set up a Form submit trigger. A trigger is a feature in Google Apps Script that enables you to automate tasks and workflows.

Once you set it up, the trigger will automatically run the sortResponses() function whenever your form is submitted. Therefore, your sheet will already be sorted with the most recent response at the top when you open it the next time.

Step 3.1 — Open the triggers page by clicking on the clock icon

Screenshot of the script editor's toolbar. The clock icon, which is used to set up triggers, is highlighted.

Step 3.2 — Click Add trigger to create a new Trigger

Screenshot of the script's triggers page. The page is empty since no triggers have been created for this script.

Step 3.3 — Configure your trigger and save it

Choose sortResponses as the function to run and choose "On form submit" as the event type. Click save to create the trigger.

Screenshot of the popup dialog where you can configure the trigger's settings.

Your trigger is now created and it should be listed on your script's triggers page.

Screenshot of the script's triggers page displaying a form submit trigger.

Step 3.4 — Test your trigger by submitting a new form response

When you submit a new response, the trigger will automatically run the sortResponses() function and your response will move to the top of your sheet.

If that did not work, try running your function manually to confirm that it works correctly (you can drag a few rows around so the sorting becomes out of order to test if running the sortResponses() function puts the rows back in the correct sort order).

Step 4 — (optional) Turn on email notifications so you're notified when your form is submitted

In addition to automatically sorting form responses, I usually also turn on email notifications in my forms so I'm notified whenever my form is submitted.

To turn notifications on in your form, select the three dots menu in the Responses tab of your form.

Then select "Get email notifications for new responses" from the menu.

Now, you'll get email notifications whenever your form is submitted and when you open the form's spreadsheet, the most recent response will be at the top!

Conclusion

In this tutorial you learned how to automatically sort your Google Form's responses so you don't have to scroll to the bottom of your form's spreadsheet to see the most recent responses.

To set this up, you need to:

You also learned how to set up email notifications so you're notified whenever your form is submitted. These two features are complementary and together they have saved me a ton of time and I hope you'll save a lot of time too.

Thanks for reading!

Master Google Sheets Automation

Sign up to receive exclusive Automation tips and tutorials!
I'll send you actionable tips on automating tasks with Google Sheets and coding with Apps Script. You'll also be notified whenever new content is published.
PLUS: Get instant access to my Birthday Reminder Template! 🎂
By signing up you agree to the Privacy Policy & Terms.

Have feedback for me?

I'd appreciate any feedback you can give me regarding this post.

Was it useful? Are there any errors or was something confusing? Would you like me to write a post about a related topic? Any other feedback is also welcome. Thank you so much!