Sorting puts your data in a useful order, such as names from A to Z, amounts from largest to smallest or dates from oldest to newest. Excel can sort by one column, by several columns at once, by cell color or by a custom order such as High, Medium, Low. It can also sort a list with a formula that updates by itself. This guide walks through each method with a small example, explains how to keep rows together so data does not get mixed up, how to sort dates and text numbers correctly, how to sort left to right, and what to do when the result looks wrong. It is useful for anyone who prepares reports, lists or client files.
Updated November 2026
In this guide
- Sort one column quickly
- The sample data
- Sort by multiple columns
- Sort by a custom list
- Sort by cell color or font color
- Sort left to right
- The SORT function for a live list
- Sort dates correctly
- Keep rows together and avoid mixing data
- Sorting problems and fixes
- Sort within a filter
- Practice exercise
- Common mistakes
Sort one column quickly
Click any cell in the column you want to sort. Go to the Data tab and click the A to Z button for ascending order, or the Z to A button for descending order. Excel sorts the whole table around that column, so each row stays together. For text, ascending means A to Z. For numbers, it means smallest to largest. For dates, it means oldest to newest. Always make sure your data has headings in the first row, and that there are no blank rows or columns inside the table, otherwise Excel may sort only part of it.
The sample data
The examples use this table in A1:C7.
| Name | Department | Salary |
|---|---|---|
| Sara | Sales | 4500 |
| Ali | Support | 3800 |
| Omar | Sales | 5200 |
| Hina | Support | 4100 |
| Bilal | Sales | 4500 |
| Zain | Support | 3800 |
Sort by multiple columns
Click inside the table and choose Data, then Sort. In the dialog, make sure My data has headers is ticked. Set Sort by to Department and Order to A to Z. Click Add Level, and set Then by to Salary with Order Largest to Smallest. Click OK. The result groups the Sales rows first, with Omar 5200, then Sara 4500 and Bilal 4500, followed by the Support rows with Hina 4100, then Ali 3800 and Zain 3800. Where two rows tie on all the chosen levels, Excel keeps their original relative order. You can add more levels, such as Name A to Z, to break the ties, and the order of the levels decides the priority.
Sort by a custom list
Some orders are not alphabetical, such as Low, Medium, High, or months from January to December. In the Sort dialog, choose the column, then in Order select Custom List. Excel offers built-in lists for days and months. To create your own, click New List, type the items in order, separated by commas or on separate lines, and click Add. For a priority column with High, Medium and Low, add that list and the sort follows your order. This is also the way to put a status such as Open, In progress and Done into the order of the workflow. You can reuse the list in other files on the same computer.
Sort by cell color or font color
If you highlighted cells manually or with conditional formatting, you can sort by color. In the Sort dialog, change Sort On from Cell Values to Cell Color, then choose the color and where it should appear, on top or at the bottom. Add a level for each color to get an exact order, such as red first, then yellow, then green. This is useful for review sheets where reviewers color cells by hand. Remember that the color is not data, so it is better to add a status column and sort by that, because colors can change by accident and are not available to formulas.
Sort left to right
Excel can also sort columns instead of rows. In the Sort dialog, click Options and choose Sort left to right. Then pick the row that contains the values to sort by. This helps with tables where months or years run across the top and you want to order the columns by a value, such as the total. Be careful to include the header column in the selection, so that the labels move with the values. For most data, it is cleaner to keep records as rows and use a normal sort, since formulas and filters work best that way.
The SORT function for a live list
In Microsoft 365, Excel 2021 and Excel 2024, =SORT(A2:C7,3,-1) returns the table sorted by the third column in descending order, with Omar 5200 first. The 3 is the column number inside the range, and -1 means descending. Use 1 for ascending. The result is a separate dynamic list, so the original data is untouched, and the list updates when the data changes. For two levels, use =SORTBY(A2:C7,B2:B7,1,C2:C7,-1), which sorts by department ascending and salary descending. Combine SORT with FILTER, as shown in our FILTER function guide, to build a sorted list of only the rows you need.
Sort dates correctly
Dates sort in the right order only if Excel stores them as real dates. If a date column is left-aligned, it is probably text, and a text sort would put 10-Jan before 2-Jan. Convert the text to dates with Text to Columns, or with DATEVALUE, as explained in our guide to converting text to numbers in Excel. For months by name, use a custom list rather than an alphabetical sort, because April would otherwise come before January. If you need to sort by month and ignore the year, add a helper column with =MONTH(A2) and sort by it.
Keep rows together and avoid mixing data
The biggest sorting accident is sorting one column by itself, so the names no longer match the salaries. Excel warns you when you select a single column next to other data, and offers to expand the selection. Always choose Expand the selection. Better still, click one cell in the table and sort from there, so that Excel detects the whole range. Convert the list to an Excel table with Insert, then Table. Tables keep every row together and show sort buttons in the headings. Before a major sort, add an ID or row number column with 1, 2, 3 and so on. If something goes wrong, you can sort by this column to return to the original order.
Sorting problems and fixes
If numbers sort as 1, 10, 2, 3, they are stored as text, so convert them. If the sort ignores some rows, there may be a blank row inside the data, which stops Excel from seeing the whole range, so remove it or select the full range first. If the headings sort into the data, the header option is off, so tick My data has headers. If merged cells block the sort, unmerge them first, since sorting does not work with merged cells of different sizes. If formulas return wrong results after sorting, check for relative references that point to other rows, and use absolute references or structured table references. Hidden rows stay hidden, and filtered rows sort only if they are visible.
Sort within a filter
When you click the arrow in a filter heading, the menu includes Sort A to Z and Sort Z to A. This works on the visible rows, and combines well with a filter that shows only one department. To turn the buttons on, select a cell in the data and press Ctrl+Shift+L on Windows, or use Data, Filter. To clear all sorting and filtering, click Clear in the Sort and Filter group. Note that sorting does not remove duplicates, so use the tools in our guide to removing duplicates in Excel first if your list has repeats. A clean, sorted list is easier to check and easier for a client to read.
Practice exercise
Copy the sample table to a new sheet and try these. First, sort by Salary from largest to smallest, and check that Omar comes first with 5200. Second, sort by Department and then by Name, and confirm that Sales comes before Support, with Bilal, Omar and Sara in order. Third, create a custom list of Support, Sales and sort by Department, so that Support comes first. Fourth, add a row number column before sorting, sort the data twice, and then use the row numbers to restore the original order. Fifth, use the SORT function on a copy and compare it with the manual result. This covers the main skills in about fifteen minutes.
Common mistakes
The most common mistake is to sort only one column, which breaks the link between the data in each row. Another is to forget the header setting. A third is to sort a range that includes a total row, which moves the total into the middle of the data. A fourth is to rely on color without a status column. A fifth is to sort text numbers and trust the order. Finally, always keep a copy of the original data or an ID column before sorting, so you can go back if the result is not what you expected.
Frequently asked questions
How do I sort data in Excel?
Click a cell in the column, go to the Data tab, and click A to Z or Z to A.
How do I sort by more than one column?
Use Data, Sort, and add a level for each additional column.
How do I sort by a custom order such as High, Medium, Low?
In the Sort dialog, choose Order, then Custom List, and create your list.
Why does Excel sort my numbers wrongly?
They may be stored as text. Convert them to numbers first.
Is there a formula to sort data?
Yes. In Microsoft 365, Excel 2021 and Excel 2024, use the SORT or SORTBY function.


