Google Docs tasks · Tables
Sort the rows of a table in Google Docs
A table typed in the order items occurred to you — names, dates, amounts in no sequence — is hard to read and harder to check. Google Docs can sort a table's rows by any column, alphabetically or numerically, in either direction, without disturbing the other columns in each row. This guide sorts a table safely: header row protected, the right column chosen, and the result checked while Undo can still rescue a wrong sort.
Sort the rows by a column
Google lists sorting among the table tools in its help on how to add and edit tables: on a computer, a table's rows can be sorted by the column you choose.
- Save the order you have, if it means anything. Sorting replaces the current row order. If the original sequence matters — arrival order, for example — add a plain number column first and number the rows as they stand, so the original order can be restored by sorting on that column.
- Click in the column you want to sort by. Put the cursor in any cell of that column, in a data row. The whole rows move together; you do not need to select the table.
- Open the Table menu and choose the sort direction. Use Table > Sort column ascending to run from A to Z or smallest to largest, or Table > Sort column descending for the reverse.
- Watch what happens to the first row. If the table has a header row of column labels, confirm it stayed at the top. If the labels sorted down into the data, undo at once with Ctrl + Z (Windows) or Command + Z (Mac) and see the snags below before trying again.
Check the sorted table
- Read down the sorted column. Check the first few rows, the last few rows, and any values you know belong in the middle. Sorting mistakes show up at the boundaries first.
- Spot-check that rows stayed whole. Pick two or three rows and confirm each value still sits beside the name or item it belongs to — a sort should move complete rows, never shuffle cells between them.
- Look at how numbers and dates ordered themselves. Values stored as plain text can sort as text, so 100 can land before 20 and dates written in mixed formats can scatter. If the order looks wrong, make the column's entries consistent in format and sort again.
Docs sorts by one column per pass. For a two-level sort — by department, then by name within each department — sort by the secondary column first and the primary column second; the second sort keeps the first sort's order inside each group in most cases. Check the result row by row if the grouping matters.
End state
- The rows run in the chosen column's order, ascending or descending as intended.
- The header row, if there is one, is still at the top and was not sorted into the data.
- Every row's cells still belong together — no value sits beside the wrong item.
- Numbers and dates in the sorted column use one consistent format, so their order is the order you expect.
When it goes wrong
- The header row sorted into the middle of the table. Undo immediately. Then either sort with the cursor placed so the header is excluded where your version offers that behavior, or move the labels out, sort, and put them back — and pin the header row afterward so it repeats on each page.
- Numbers sorted as 1, 10, 2, 20. The column is being read as text. Remove stray spaces or characters from the entries, keep them as plain numbers, and sort again.
- Dates came out in a jumble. Mixed formats — some typed as month/day, some written out — sort inconsistently. Rewrite the column in one format and re-sort.
- There is no Sort item in the Table menu. Sorting is a computer feature; open the document in Docs in a browser on a computer rather than in the mobile app, and click inside the table first so the Table menu shows its row tools.
- Only part of the table sorted. Merged cells or a table split across an interruption can break the sortable block. Undo, remove any merged cells in the sort column, and sort again.
Related document tasks
-
Make a Google Docs table repeat its header row on every page
Make a Google Docs table repeat its header row on every page: pin the top row in Table properties so the column labels follow the table across page breaks, and fix the tables that still split badly.
-
Create a Google Docs document from a table pasted out of a PDF
Create a Google Docs document from a table pasted out of a PDF: try the direct paste, clean up what lands in one column, rebuild the table properly with Insert Table, or open the PDF with Google Docs when the table is large.
-
Create a table of contents in Google Docs and keep it updated
A long document without a table of contents makes readers scroll and guess.
-
Add a caption under a picture in Google Docs
Add a caption under a picture in Google Docs: put the picture in line and type the caption beneath it, or hold picture and caption together in a borderless two-row table so they move as one block.
Sources
- Google Support, Add and edit tables — sorting table rows on a computer, moving rows, and pinning header rows so they repeat at the top of each page.