Sorting puts your data in order so you can find patterns and read information faster
Sorting in Excel rearranges rows based on the values in one or more columns. You can sort alphabetically, numerically, by date, or by custom order. Excel keeps entire rows together when you sort, so if you have names in column A and phone numbers in column B, the phone numbers stay matched to the correct names.
The most common sorts are A to Z (or Z to A), smallest to largest (or largest to smallest), and oldest to newest (or newest to oldest). You can also sort by color, by icon, or by multiple columns at once — for example, sort by state first, then by last name within each state.
Key Takeaways
- Select your entire data range before sorting, or click any cell in your data and let Excel detect the range automatically.
- Use the Data tab on the ribbon, then choose Sort A to Z, Sort Z to A, or Sort to open the dialog for more control.
- Excel keeps rows together during a sort, so related information in different columns stays matched.
- Sort by multiple columns by opening the Sort dialog and adding sort levels — for example, sort by region first, then by sales amount within each region.
- Undo a sort immediately with Ctrl+Z if the result is not what you expected.
How to sort a single column from A to Z or Z to A
Click any cell in the column you want to sort. You do not need to select the entire column. Go to the Data tab on the ribbon at the top of the screen. Click Sort A to Z to arrange text alphabetically or numbers from smallest to largest. Click Sort Z to A to reverse the order.
Excel will automatically detect your data range and sort all rows together. If your data has headers (like "Name" or "Email" in the first row), Excel recognizes them and does not sort them into the data. If Excel sorts your headers by mistake, undo the sort with Ctrl+Z, then select your data without the header row and try again.
How to sort by multiple columns at once
Click any cell in your data. Go to the Data tab and click Sort (not Sort A to Z). The Sort dialog opens. In the first row under "Column", choose which column to sort by first — this is your primary sort. Under "Sort On", leave it set to "Values" unless you are sorting by cell color or icon. Under "Order", choose A to Z, Z to A, smallest to largest, or largest to smallest.
To add a second sort level, click Add Level. Choose a different column for the second sort. For example, if you sorted by State first, you can now sort by Last Name second. Excel will keep all rows in each state together, and within each state, arrange them alphabetically by last name. You can add up to 64 sort levels, though three or four is typical.
Click OK when you are done. Excel sorts your data and closes the dialog.
How to sort by date or time
Click any cell in the column with dates or times. Go to the Data tab and click Sort. In the Sort dialog, choose your date column under "Column". Under "Order", you will see options like "Oldest to Newest" or "Newest to Oldest" if Excel recognizes the column as dates. Choose the order you want.
If Excel does not recognize your dates and shows only A to Z and Z to A, your dates may be stored as text instead of as actual date values. This happens when dates are typed as text or imported from another program. You can still sort them, but the order may not be correct. To fix this, format the column as a date: select the column, right-click, choose Format Cells, click the Number tab, and choose Date from the Category list.
How to sort by color or icon
If you have colored cells or cells with icons (small images), you can sort by those instead of by the actual values inside. Click any cell in the column with colors or icons. Go to the Data tab and click Sort. In the Sort dialog, under "Sort On", click the dropdown and choose Cell Color or Cell Icon instead of "Values".
Under "Order", choose which color or icon goes first. You can drag colors or icons up and down to set the order you want. Click OK when done. This is useful when you have flagged important rows with color or icons and want to group them at the top.
What to do if your sort goes wrong
Press Ctrl+Z immediately to undo the sort and return to the original order. This works as long as you have not made other changes since the sort.
The most common mistake is sorting only part of your data. If you selected just one column before sorting, Excel sorted that column but left the other columns in place, breaking the connection between rows. Undo with Ctrl+Z, then click any cell in your data and repeat the sort — do not select a range first, let Excel detect it.
Another common issue is sorting when you have blank rows or columns in the middle of your data. Excel may treat the blank area as the end of your data and sort only part of it. Remove blank rows and columns before sorting, or select your exact data range before you sort.
How to sort custom lists and non-standard orders
Excel has built-in custom lists for days of the week (Monday, Tuesday, Wednesday) and months (January, February, March). If your data uses these, Excel sorts them in calendar order, not alphabetically. For example, "Monday" comes before "Tuesday" even though M comes before T.
If you need a different custom order — for example, "Small", "Medium", "Large" — you can create one. Go to File, then Options. Click Advanced in the left sidebar. Scroll down to "General" and click Edit Custom Lists. Click New List, type your values in order (one per line), and click Add. Now when you sort, you can choose this custom list as your sort order.
Frequently Asked Questions
Can I sort without headers?
Yes. If your data has no header row, Excel will sort all rows including the first one. If your first row is a header, select it before sorting and Excel will recognize it automatically. If Excel treats your header as data, undo and try the sort again — Excel usually learns after the first attempt.
What happens to formulas when I sort?
Formulas move with their rows. If a formula in row 5 refers to a cell in the same row, that reference moves too. Formulas that refer to a fixed range (like a total at the bottom) will still refer to that range after the sort, which is usually what you want.
Can I sort by more than one column?
Yes. Open the Sort dialog, add multiple sort levels, and choose the order for each. Excel applies them in order — it sorts by the first column, then by the second column within each group of the first column, and so on.
Does sorting change my original data?
Yes, sorting rearranges your data permanently. If you want to keep the original order, make a copy of your sheet first, then sort the copy. You can also undo a sort immediately with Ctrl+Z if you change your mind.
Why does my sort put numbers in the wrong order?
Numbers stored as text sort alphabetically instead of numerically — for example, "9" comes after "10". Select the column, right-click, choose Format Cells, click the Number tab, and choose Number from the Category list. Then sort again.