How to Sort Data in Google Sheets (Without Messing Up Your Rows)

By Gerard Fernandez · Updated · 3 min read

Sorting puts your rows in order: names A to Z, the biggest expenses first, the newest dates at the top. The key is to sort whole rows together, so a name never ends up next to someone else's number. Here are the safe ways to do it in Google Sheets.

Sort a range by one column

  1. Select the whole table you want to sort, including the header row. For example A1:C8.
  2. Go to Data → Sort range → Advanced range sorting options.
  3. Tick Data has header row. The header stays at the top and the Sort by list now shows your column names instead of letters.
  4. In Sort by, choose the column to sort on. Pick A to Z (smallest first) or Z to A (largest first).
  5. Click Sort.
Google Sheets Data menu with Sort range open showing Sort range by column A (A to Z), (Z to A) and Advanced range sorting options, with A1:C8 selected
Real test: the quick options sort by the first column of your selection. For anything else, use Advanced range sorting options.
Sort range from A1 to C8 dialog with Data has header row ticked, sort by Amount, Z to A selected
Real test: sorting expenses by Amount, largest first.
Expense list sorted by amount from 60 down to 4, with each date and category still on the same row and the header still at the top
Real test: every row moved as a unit. Each amount kept its date and category, the header stayed at the top, and the alternating colors stayed in order.

Don't select just one column. If you select only the Amount column and sort it, only that column moves, and every amount ends up next to the wrong item. Always select the full table, or use Sort sheet (below).

Sort by several columns

In the same dialog, click Add another sort column. Sheets sorts by the first column, and uses the second one only to order rows that tie on the first. For example, sort by Category A to Z, then by Amount Z to A, to see each category with its biggest expense first.

Sort the whole sheet

If your table is the only thing on the sheet, you can sort everything at once:

  1. Freeze the header row first with View → Freeze → 1 row (see how to freeze rows).
  2. Click any cell in the column you want to sort by.
  3. Go to Data → Sort sheet and choose Sort sheet by column (A to Z) or (Z to A).

Frozen rows are left in place, so your header stays at the top.

Keep a sorted copy with the SORT function

Sorting with the menu changes your data permanently. If you'd rather keep the original order and show a sorted version somewhere else, use a formula:

=SORT(A2:C7, 3, FALSE)

The arguments are the range, the column number within that range to sort by (3 = Amount), and TRUE for ascending or FALSE for descending. The result updates automatically when the source data changes. In our test, =SORT(A2:C8, 1, TRUE) next to the table listed the same rows by date, oldest first, while the original stayed sorted by amount. To sort by more columns, add more pairs: =SORT(A2:C7, 1, TRUE, 3, FALSE).

Dates in the wrong order? Some of them are probably text. See sort by date not working.

Frequently asked questions

Why did my header row get sorted into the data?

"Data has header row" wasn't ticked. Press Ctrl + Z to undo, then sort again with the box ticked.

Why are numbers sorted in the wrong order (1, 10, 2…)?

They're stored as text. Select the column and choose Format → Number → Number, then sort again.

Why does Sheets say "You can't sort a range containing vertical merges"?

Some cells in the range are merged across several rows. Unmerge them and fill in the empty cells first. See how to fix the vertical merges error.

Can I undo a sort?

Yes, with Ctrl + Z right away. If you might need the original order later, add a column with 1, 2, 3… before sorting, so you can always sort back by it.