The quickest way to sort numbers in Excel
Click any cell in the column of numbers you want to sort, then click the Data tab at the top of the screen. You will see a button labeled Sort A to Z (for smallest to largest) or Sort Z to A (for largest to smallest). Click the one you need, and Excel rearranges the entire column in seconds.
That is the whole process for a single column. If your spreadsheet has multiple columns — like a list of names with their ages, or products with their prices — you need one extra step so Excel knows to keep each row together. That step is explained in the section below.
Excel assumes you want smallest to largest when you click Sort A to Z, even though the button label uses letters. The same button works for numbers.
Key Takeaways
- Click any cell in the column you want to sort, then click Data at the top, then Sort A to Z for smallest to largest.
- If your spreadsheet has multiple columns, select all the data first so Excel keeps rows together instead of scrambling them.
- The Sort button (not Sort A to Z) opens a menu where you can sort by a column other than the one you clicked, or sort largest to smallest without a button click.
- Excel treats blank cells and text as separate from numbers, so they may end up at the top or bottom of your sorted list.
Sorting multiple columns without scrambling your data
When you have a spreadsheet with names in one column and numbers in another — or any setup where columns belong together — you must select all the data before sorting. Click the first cell of your data, then hold Shift and click the last cell. This highlights everything in between. Now click Data and then Sort A to Z.
Excel will sort by the column you originally clicked, but it keeps each row intact. If you sorted by age, the names stay matched to their ages instead of getting shuffled around.
If you want to sort by a different column than the one you clicked, use the Sort button (not Sort A to Z) instead. This opens a menu where you can choose which column to sort by. This is also the place to go if you want largest to smallest and do not want to click Sort Z to A.
What happens to blank cells and text mixed with numbers
Excel treats blank cells, text, and numbers as three separate categories. When you sort, blanks usually float to the top, then text, then numbers. If your column has a mix — like some cells with ages and some with "Unknown" — the numbers will sort among themselves, but the text entries will cluster separately.
If this is not what you want, clean up the column first. Replace "Unknown" with a number like 0, or delete the text entries entirely. Then sort. This keeps everything in one logical order.
Sorting by multiple columns at once
Sometimes you need to sort by one column, then by a second column within that. For example, you might want to sort by state first, then by city within each state. Select all your data, click Data, then click the Sort button (the one that opens a menu, not the Sort A to Z shortcut).
A dialog box will open. The first dropdown shows which column to sort by. Below that, you can add a second sort level. Click Add Level, then choose the second column. Excel will sort by the first column, and within each group of the first column, it will sort by the second.
You can add as many levels as you need, though three or four is usually the practical limit before the result becomes hard to read.
Undoing a sort if it went wrong
If you sorted and the result scrambled your data, press Ctrl+Z (or Cmd+Z on a Mac) when ready. This undoes the sort and puts everything back the way it was. You have unlimited undos in Excel, so do not panic if a sort does not look right.
If you realize the mistake hours later, undo still works — just keep pressing Ctrl+Z until you reach the point before the bad sort. However, if you have saved the file since the sort, undo will not work. In that case, close the file without saving and reopen the last saved version.
Sorting numbers that look like text
Sometimes a column of numbers sorts wrong — like 2 appearing after 10, or 100 before 20. This usually means Excel is treating the numbers as text instead of actual numbers. This happens when numbers are entered with an apostrophe in front (like '100) or when they come from another program that formatted them as text.
To fix this, select the column, click Data, then look for a button or option labeled Text to Columns. Click it, then click Finish in the dialog that appears. Excel will convert the text to real numbers, and sorting will work correctly after that.
If Text to Columns does not appear, the numbers are probably already real numbers and something else is causing the odd sort order. Check whether the column contains spaces or special characters before the numbers, which can throw off the sort.
Sorting while keeping a header row in place
Most spreadsheets have a header row at the top — like "Name", "Age", "City" — that should not move when you sort. Excel usually detects this automatically. When you select your data and sort, Excel recognizes the header and leaves it at the top.
If your header row gets sorted into the data by mistake, undo when ready with Ctrl+Z. Then select only the data rows (not the header), and sort again. Or, select all the data including the header, click Data, then click the Sort button to open the menu. At the bottom of the dialog, check the box that says My data has headers. This tells Excel to treat the first row as a label and keep it in place.
Frequently Asked Questions
Can I sort by a column without moving the other columns?
No. Excel sorts entire rows together to keep your data intact. If you sort by one column, all columns move with it. This is actually a feature — it prevents your data from getting scrambled. If you need to sort one column independently, copy it to a new sheet first, sort it there, then copy it back.
What is the difference between Sort A to Z and the Sort button?
Sort A to Z is a shortcut that sorts the column you clicked from smallest to largest in one click. The Sort button opens a menu where you can choose which column to sort by, sort largest to smallest, add multiple sort levels, or tell Excel to ignore a header row. Use the shortcut for straightforward sorts; use the button for anything more complex.
Why do some numbers sort in the wrong order?
Excel is probably treating them as text instead of numbers. This happens when numbers are entered with an apostrophe, come from another program, or have spaces before them. Select the column, click Data, then Text to Columns, and click Finish. This converts them to real numbers so sorting works correctly.
Can I sort by more than one column at a time?
Yes. Select all your data, click Data, then click the Sort button to open the menu. Choose your first column to sort by, then click Add Level and choose a second column. Excel will sort by the first column, then by the second within each group. You can add as many levels as you need.
How do I sort from largest to smallest instead of smallest to largest?
Click the Sort Z to A button instead of Sort A to Z. Both are in the Data tab. If you want to use the Sort menu instead, select your data, click Data, then Sort, and choose "Descending" in the dialog box.