GuidesGoogle Sheets

How to sort a table in Google Sheets

Learn how to sort a table in Google Sheets by one or more columns, keep headers in place, and preserve row data correctly.

Quick answer

To sort a table in Google Sheets, select the data range including the header row, go to Data > Sort range, check Data has header row, choose the column to sort by and the order (A–Z or Z–A), and click Sort.

Steps at a glance

  1. Select all cells in your table, including the header row.
  2. Go to Data > Sort range > Advanced range sorting options.
  3. Check Data has header row.
  4. Choose the column to sort by and select A→Z or Z→A.
  5. Click Sort.

Interactive demo

Loading demo…

This interactive demo was created free with Arclet in 3 minutes.

Create your own demo →

Summary

Sorting a table in Google Sheets keeps all rows intact while reordering them by the values in a chosen column. Using Sort range with Data has header row ensures the header stays at the top. You can add multiple sort columns for secondary sorting — for example, sort by department first, then by last name within each department.

Step-by-step guide

  1. Step 1

    Select the table range

    Click and drag to select all cells in your table, including the header row. Make sure the selection covers all columns so rows are sorted as complete units.

  2. Step 2

    Open Sort range

    Go to Data > Sort range > Advanced range sorting options. A dialog box opens with sorting configuration.

  3. Step 3

    Check Data has header row

    Tick the Data has header row checkbox. The sort column dropdown now shows your column names instead of letters, and the header row is excluded from sorting.

  4. Step 4

    Choose sort column and order

    Select the column name you want to sort by from the dropdown. Choose A→Z for ascending or Z→A for descending. Click Add another sort column to add a secondary sort key.

  5. Step 5

    Apply the sort

    Click Sort. The table rows reorder immediately based on your selections. The header stays in place at the top.

Why this matters

You've got a table of results and you need to see the highest values first, or group rows by a particular column, before you share it with the team or paste it into a report.

Troubleshooting

  • The header row is being sorted along with the data

    In the Sort range dialog, check Data has header row to protect the first row from sorting.

  • Only part of the table is sorting and some rows are being left behind

    The selected range did not include all columns. Select the entire table (all rows and columns) before opening Sort range.

Frequently asked questions

  • Can I sort a table by color in Google Sheets?

    Yes. Use Data > Create a filter, then click the filter icon in the column header and choose Sort by color to sort rows by cell background or text color.

  • Does Google Sheets support sorting by a custom list order?

    Not natively. For custom order sorting (e.g., sorting months in calendar order rather than alphabetically), you would need to add a helper column with numeric sort keys and sort by that.

Create interactive demos like this one — free, no coding required.

Start for free →