How to Sort in Excel and Google Sheets

How-to basics · Updated November 3, 2026

How to Sort in Excel and Google Sheets

To sort data without separating related values, select a cell in the complete table, open the sort controls, choose the column and order, and confirm that the header row is identified correctly. In Excel for Microsoft 365 on Windows, use Data > Sort; in Google Sheets in a browser, use Data > Sort range for a selected table. The key is sorting whole rows, not a single column by itself.

Sorting puts records into a useful order, such as names from A to Z, dates from oldest to newest, or sales figures from largest to smallest. The steps below cover both programs; menu names and options are identified separately so you can follow the instructions for the spreadsheet you are using.

What You’ll Need

  • A workbook in Excel for Microsoft 365 on Windows, or a spreadsheet open in Google Sheets in a web browser.
  • A rectangular block of data, with each record on one row and each type of information in its own column.
  • Clear column headings, such as Name, Date, or Amount. Headings make it easier to choose the right sort field and avoid sorting them along with the records.
  • If the data is important, save the Excel workbook or make a copy of the Google Sheet before trying a complicated sort. A simple sort can usually be undone, but a copy gives you a reliable fallback.

Step-by-Step

  1. Check that the records form one table.

    Each row should describe one item, person, or transaction, and each column should contain one kind of information. For example, a contact list might have Name, City, and Email columns. Remove completely blank rows or columns from the middle of the data, because they can make a program treat part of the table as a separate block. A title or note above the table is fine, but do not include it in the range you intend to sort.

  2. Decide whether to sort the whole table or just a range.

    Usually, sort the entire table so that every value in a record moves together. If you sort only the Name column while leaving Email and City in place, the names will no longer match their original details. In Excel, click a cell inside the data and the sort command will generally detect the surrounding block. In Google Sheets, select the full table range if you are using Sort range. If your sheet has other unrelated information beside or below the table, make the selection precise.

  3. Choose the sort column and direction.

    Pick the field that answers your question. Use A to Z for ascending text, Z to A for descending text, oldest to newest for dates, or smallest to largest for numbers. The reverse options are useful for finding the newest date or highest value first. If the column contains dates or numbers, make sure they are stored as dates or numbers rather than text; otherwise, the order may look unexpected.

  4. Sort in Excel for Microsoft 365 on Windows.

    Click a cell inside the table, then choose Data > Sort & Filter > Sort. In the Sort dialog box, check My data has headers if the first row contains column names. Under Sort by, select the heading for the column to use. Leave Sort On set to Cell Values for an ordinary text, number, or date sort. Choose the desired option under Order, then select OK.

    For a quick one-column sort, click a value in that column and use Data > Sort A to Z or Data > Sort Z to A. If Excel asks whether to expand the selection, choose Expand the selection to keep each row together. Choose Continue with the current selection only when you intentionally want to rearrange that column independently, which is uncommon for a table of related records. On Excel for Mac, the Data tab also has Sort and ascending or descending sort commands; dialog labels are similar, though ribbon layout can vary by version.

  5. Sort a selected range in Google Sheets.

    Highlight all the cells in the table, including its headings, then choose Data > Sort range > Advanced range sorting options. In the dialog, check Data has header row if the first selected row contains headings. Choose the column to sort by, select either A to Z or Z to A, and click Sort. The selected rows will move together, preserving the relationship among the columns.

    If the table occupies the whole sheet and there is no unrelated content to protect, you can use Data > Sort sheet and choose a sort direction for the column. Be cautious with that option: it sorts the sheet, not just a small highlighted block. Google Sheets in a browser may show slightly different wording for the selected column, but the sort direction and header-row setting are the important choices.

  6. Add a second sort level when values repeat.

    A second level organizes ties within the first sort. For example, sort a staff list by Department from A to Z, then by Last Name from A to Z. In Excel, open Data > Sort & Filter > Sort, set the first column, then click Add Level and select the second column and its order. Excel applies the first level, then orders matching entries by the next level. In Sheets, open Data > Sort range > Advanced range sorting options, set the first column, and choose Add another sort column to add the next one. Set levels in the priority order you want.

  7. Check the result before continuing.

    Look at the first and last few records, confirm the headings stayed at the top, and verify that values across each row still belong together. For a date sort, check that the order is chronological rather than alphabetical. If the result is wrong, immediately use Undo: Ctrl+Z in Windows, or Command+Z on Mac. Google Sheets also has an Undo command in the toolbar and under Edit. Undo promptly, before making other edits that you need to keep.

  8. Use a filter when you need to sort repeatedly.

    In Excel, use Data > Filter to add filter arrows to the header row; the arrows let you sort or filter from a column. In Sheets, choose Data > Create a filter. A filter is useful when you want to show only particular records and then sort the visible data. In a shared Google Sheet, a filter view can let you arrange or filter your view without changing how the sheet appears to other collaborators; choose Data > Filter views to work with that feature.

Common Mistakes

  • Sorting just one column: This can scramble the relationship between names and their associated details. Sort the entire data range or use a table-aware sort, and expand Excel’s selection prompt when appropriate.
  • Including a heading as a record: If the header row is not identified, a heading such as Date may move into the data. In Excel, check My data has headers; in Sheets, check Data has header row.
  • Selecting unrelated cells: Sorting a large area that includes notes, totals, or another table can move information that should stay put. Select only the intended table in Sheets, and keep unrelated Excel content outside the detected data block.
  • Expecting text to sort like numbers: Values such as 2, 10, and 100 may be ordered unexpectedly if some are stored as text. Check formatting and data consistency before sorting.
  • Using the wrong direction: A to Z is ascending for text, while Z to A is descending. For dates and numbers, use the labels shown for oldest/newest or smallest/largest when available and verify the result.
  • Sorting a sheet with separate sections: A whole-sheet sort can mix sections that are meant to remain independent. Select and sort a specific range instead, and make sure the range includes every column belonging to those records.

Tips

  • Keep one header row and avoid merged cells in the data area. Merged cells can interfere with selecting, filtering, and sorting a rectangular table.
  • Use a second or third sort level to make repeated values easier to scan. A practical order is often Category first, Date second, and Name third.
  • Convert a regular Excel range to a table with Insert > Table if you add records frequently. Confirm that My table has headers is selected when appropriate. Excel tables make it easier to work with named headers and include new rows as the table grows.
  • In Sheets, apply a filter to the header row if people need to sort or filter the same data often. Use filter views if collaborators need different temporary views of a shared sheet.
  • For a custom order, such as High, Medium, Low, alphabetic sorting may not match the priority you intend. Excel’s Sort dialog has a Custom List order option. In Sheets, you can add a helper column with a numeric priority, sort by that helper column, then hide it if appropriate.
  • Freeze the header row when working with a long list so the headings remain visible as you scroll. In Sheets, choose View > Freeze; in Excel, use View > Freeze Panes.
  • For a one-off reordering, save or duplicate the original first if the data is valuable. Sorting changes row order, which may affect how you review or export the sheet even when the values are intact.

Troubleshooting

Rows no longer match after sorting: Undo immediately. Select the full table, including all related columns, and repeat the sort. If Excel asks whether to expand the selection, choose Expand the selection. In Sheets, return to the original order if necessary, then select the complete range before sorting.

The header moved into the data: Undo, reopen the sort options, and mark that the range has a header row. If there is no header, leave the option off and select only the actual data. Check that your selected range starts on the correct row.

Dates or numbers appear out of order: Some entries may be stored as text, include leading spaces, or use inconsistent formats. Inspect a few affected cells and standardize their format and contents. A value that looks like a date may be plain text, so changing its display format alone may not convert it. Correct the underlying entries, then sort again.

Some rows did not move: Look for blank rows or columns splitting the data into sections, or confirm that the range covered all records. Check whether a filter is hiding rows, and remove or adjust it if you want to work with the full list. In Sheets, verify that you sorted the intended range rather than a different range or the whole sheet.

The sort command is unavailable or the result is blocked: Check whether the sheet or range is protected, whether cells are merged, or whether you have permission to edit. Remove or adjust protection only if you are authorized, and unmerge cells in the data area if needed. In a shared spreadsheet, ask the owner about access or use an allowed filter view.

Frequently Asked Questions

Can I sort by more than one column?
Yes. In Excel, use Add Level in the Sort dialog. In Google Sheets, use Add another sort column in the advanced range sorting options. Put the most important sort field first.

Will sorting change the values in my spreadsheet?
A normal sort rearranges rows; it does not rewrite their values. However, formulas that refer to cells may update according to spreadsheet reference rules, and an incorrect selection can separate related data. Check the result and use Undo if it is not right.

Can I sort only the rows that are visible after filtering?
Filter controls let you work with displayed records, but behavior can depend on how the data and filter are set up. In Excel, sorting a filtered list sorts the list while keeping rows together. In Sheets, sort the intended range or use a filter view, and inspect the result to confirm hidden or unrelated rows were not included unexpectedly.

How do I sort by color?
Excel’s Sort dialog can sort by cell color, font color, or icon when those options are available in the selected data. Google Sheets supports sorting a range by fill color or text color through its sort options when the range contains those formatting colors. Choose the relevant color and position, then check the ordering.

Can I restore the original order after sorting?
Use Undo right after the sort. If you need to restore the original order later, add an index column before sorting, fill it with the original sequence, and sort by that column when you want to return to the starting order.

Why are blank cells appearing at the top or bottom?
Blank entries commonly sort to one end of the range, and their position can depend on the program and sort direction. If blanks are unexpected, check for empty cells in the sort column and decide whether to fill, remove, or keep those records before sorting.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.