How to Sort Data in Excel (Basic Guide) | Step-by-Step

Step-by-step instructions for simple sorting.

Most people think sorting in Excel is the easy part — the thing you do before the real work starts. That's mostly true, except for the part where it silently scrambles your data and you don't notice until three steps later. Sorting is one of those foundational tasks that takes two clicks when everything's set up correctly and twenty minutes of confusion when it isn't. After nearly two decades of working with spreadsheets (and years as the person my team brought their broken files to) I've seen the same sorting mistakes repeat constantly. This guide is written for the reader who's tried before and had something go wrong.

I'm going to walk you through how to sort data in Excel the right way: starting with a safety net, then covering single-column sorts, multi-level custom sorts, and the dynamic SORT function. The common mistakes section at the end is where I think this guide earns its keep.


What You Can Sort in Excel — and One Habit to Build Before You Touch the Data

Basic sorting lets you reorder any data range by one or more columns: alphabetically, numerically, by date, or by cell color. A sales pipeline sorted by deal value. An HR roster sorted by department. A Q3 report sorted by close date. Excel handles all of it the same way.

Before you touch the Data tab, build one habit. It'll save you eventually — probably sooner than you expect.

Add an Index Column First So You Can Always Undo a Sort in Excel

Excel's Undo button (Ctrl+Z) reverses a sort if you catch the mistake immediately. Close the file, reopen it, run another sort — and Undo won't help you at all. The fix is simple: before sorting, add a helper column to the left or right of your data range, label it "Index," and fill it with sequential numbers starting at 1. If the sort produces wrong results, you can re-sort by that index column and restore the original order exactly.

Takes thirty seconds. I've watched people skip it and spend an hour trying to reconstruct original row order from memory. Add the index column. Then sort.

If you're working on a Mac, the sorting interface is slightly different. The guide to sorting and filtering in Excel on Mac covers those differences in full. And if you're newer to Excel generally, the Excel for Beginners starter guide gives the broader context this article assumes.


Step 1: Sort a Column in Excel Using the Ribbon or Right-Click Menu

Once your index column is in place, you're ready to run your first sort. Click any cell inside your data range — you don't need to select the whole thing. Excel will detect the surrounding data automatically.

From the Data tab on the ribbon, click Sort A to Z (ascending) or Sort Z to A (descending). You can also right-click any cell in the column you want to sort by, choose Sort, and pick your direction from the submenu. Both routes produce identical results.

When the dialog asks whether to expand the selection, always say yes. Expanding the selection means Excel moves the entire row — every cell in that row — when it reorders your data. If you don't expand, only the column you selected moves, and your data gets misaligned. Marcus Rivera's sales figures end up on Sarah Chen's row. It's not recoverable without that index column.

Ascending vs. Descending Order: Which to Pick and When

Ascending order runs A to Z for text, smallest to largest for numbers, and oldest to newest for dates. Descending order reverses all three. For a sales pipeline, descending order by deal value puts your largest opportunities at the top — which is almost always what you want. For an employee roster, ascending order by last name keeps it readable. To sort by date in Excel, the logic is the same: just make sure your dates are stored as actual date values and not text strings formatted to look like dates. If they're text, the sort will be alphabetical, not chronological.


Step 2: Run a Custom Sort in Excel to Sort by Multiple Columns at Once

A single-column sort works fine until your data has ties. Sort an HR roster by department and everyone in Sales is grouped together — but in random order within that group. That's where the custom sort comes in.

On the Data tab, click Sort (not the A-Z or Z-A shortcut — the full Sort button). This opens the Sort dialog, where you can add multiple sort levels and control exactly which column Excel processes first.

Set Your Sort Levels So Excel Processes Them in the Right Order

In the Sort dialog, your first level is the primary sort: the column Excel organizes first. Click Add Level to add a secondary sort that applies within each group of identical values in the primary column. For the HR roster: Level 1 is Department (ascending), Level 2 is Last Name (ascending). Excel groups all the Accounting rows together, alphabetizes the names within Accounting, then moves to the next department.

In Microsoft 365 and Excel 2021, the dialog also offers Sort by Cell Color — useful when you've color-coded priority rows and want them surfaced to the top. If you need a deeper walkthrough of that specific feature, the article on sorting by cell color, font color, and icons covers the full options.

If your sort range includes merged cells, the sort will fail or produce wrong results. Merged cells and sorting do not get along. Unmerge before you sort.


Step 3: Use the SORT Function in Excel 365 for Results That Update Automatically

Everything covered so far is a static sort: you run it, the data moves, and it stays there until you sort again. The SORT function works differently. It outputs a sorted version of your data to a new range, and that output updates automatically when the source data changes.

This function requires Microsoft 365 or Excel 2021. It is not available in Excel 2019 or Excel 2016. If you're on an older version, skip this section.

Basic syntax: =SORT(array, sort_index, sort_order). To sort a table of sales data in A2:C20 by the second column in descending order: =SORT(A2:C20, 2, -1). The result spills into the cells below automatically — that's the dynamic array formula behavior. Clean, low-maintenance, and worth knowing about. Just check your version before you try it.


Common Mistakes When You Sort Data in Excel — and How to Stop Making Them

I used to think sorting tutorials were too short because the topic is simple. After watching people hit the same four problems repeatedly — including one colleague who spent three hours every Friday manually reorganizing data she could have sorted in two clicks if she'd known what was breaking — I think they're short because most authors only show the happy path.

Here are the four mistakes worth knowing about before they cost you time.

  1. Sorting a single column without expanding the selection. This misaligns your rows. Always expand the selection when Excel asks — or click any cell inside the full data range before you sort rather than selecting one column manually.
  2. Blank rows or columns inside your data range. Excel treats a blank row as the edge of the data range. Anything below it doesn't sort. Scan for blank rows before running a sort and delete them or fill the gap.
  3. Mixed data types in the sort column. A column that looks like numbers but contains some values stored as text will sort incorrectly. Numbers sort before text, so the order looks plausible but some rows land wrong. If a few rows end up in the wrong place after a sort, check the cell format of the outliers.
  4. Forgetting to add an index column first. Once you've closed and reopened the file, Undo is gone. The index column is the only reliable way to reverse a sort in Excel after the fact. For a full breakdown of what else can go wrong — and how to fix it — the common sorting errors guide is the most detailed resource on this topic.

One more thing that trips people up quietly: trailing spaces. "Acme Corp " and "Acme Corp" sort as two different values. If your text-based sort produces results that look almost right but a few names or labels end up out of place, run =TRIM() on that column before you sort. It's the same problem that breaks VLOOKUP lookups, and the fix is identical.

If you take one thing from this article: add the index column before you sort. Everything else you can troubleshoot after the fact. The original row order — once it's gone — is the one thing you can't reconstruct without it.

Frequently Asked Questions

How do I sort multiple columns at once in Excel?

Open the custom Sort dialog from the Data tab — click the full Sort button, not the A-Z shortcut. Use Add Level to add a secondary sort column. Excel processes your sort levels top to bottom, so put your primary grouping column in Level 1 and the tiebreaker in Level 2.

Why is my Excel sort not working correctly?

The most common causes are blank rows splitting the data range, merged cells in the sort range, or mixed data types in the sort column (some values stored as text, others as numbers). Check all three before running the sort again. Trailing spaces on text values are another quiet culprit — TRIM the column and retry.

What's the difference between the Sort button and the SORT function in Excel?

The Sort button on the Data tab rearranges your existing data in place — it's static. The SORT function outputs a sorted copy of your data to a new range, and that output updates automatically when the source data changes. The SORT function requires Microsoft 365 or Excel 2021 and is not available in Excel 2019 or earlier.

How do I reverse or undo a sort in Excel?

Ctrl+Z will undo a sort if you haven't closed the file yet. After closing and reopening, Undo is no longer available. The reliable solution is to add a numbered index column before sorting — re-sort by that column and your original row order is fully restored.