To sort numbers in Excel, select a cell in the number column, then choose Data > Sort Smallest to Largest for ascending order or Data > Sort Largest to Smallest for descending order. Excel normally expands the selection to include adjacent data, so each row stays together; for more control, use Data > Sort and select the column and order explicitly.
What sorting numbers in Excel does
A numeric sort rearranges records according to the values in a chosen column. Smallest to Largest puts lower values first, while Largest to Smallest puts higher values first. For example, sorting scores of 72, 95, 81, and 68 from smallest to largest gives 68, 72, 81, and 95. If the scores belong to student names, Excel should move each entire row, not just the score cells.
Sorting changes the order of worksheet rows; it does not change the underlying numeric values. It is also different from filtering. A sort displays all the records in a new order, whereas a filter hides rows that do not meet criteria. You can use both together, such as filtering a sales table to one region and then sorting the visible sales from largest to smallest.
In Microsoft Excel for Microsoft 365 on Windows, the quick sort buttons are on the Data tab. The same basic commands are available in desktop Excel for Mac and Excel for the web, although ribbon layout and keyboard navigation can differ. If a column contains headers, the full Sort dialog offers a setting to identify them so the header is not treated as a value.
Sort a number column while keeping rows together
For a typical list with headers, use this process:
- Click one cell in the column containing the numbers. Avoid selecting just the numeric cells if other columns in the same records must move with them.
- Open the Data tab and choose Sort Smallest to Largest or Sort Largest to Smallest.
- If Excel asks whether to expand the selection, choose Expand the selection to keep each record intact, then choose Sort.
- Check a few rows to confirm the related names, dates, or other fields stayed with the correct numbers.
When Excel recognizes a continuous block of neighboring data, it usually expands the range automatically. The prompt is a safeguard: sorting only the selected number cells can separate values from their corresponding records. If the worksheet has blank columns or rows splitting the data, Excel may not recognize the full table. In that case, select the complete rectangular range first, including all columns that belong to the records, then sort it.
For a one-column list with no related data, selecting the cells and sorting them directly is appropriate. If there is a header such as Amount or Quantity, include it in the selection and use the Sort dialog to mark the range as having headers.
Use the Sort dialog for a specific column
The Sort dialog is useful when a worksheet has several number columns, a header row, or more than one sorting rule. Select a cell in the data range and choose Data > Sort. In the dialog, select the relevant field under Column, choose Values under Sort On, and set Order to Smallest to Largest or Largest to Smallest. If the first row contains labels, enable My data has headers.
The dialog makes the sort key explicit. Suppose a table has Item, Units, and Revenue columns. Clicking a quick-sort button while the active cell is in Revenue sorts by Revenue, but the dialog lets you confirm that Revenue—not Units—is the chosen column. It also provides controls for secondary levels, cell color, font color, and icon-based sorts when those are relevant.
On Windows, Excel key tips can open the sort controls from the keyboard: press Alt, then A, then S, followed by A for ascending or D for descending, subject to the key tips shown in the installed Excel build. On Mac there is no identical Alt key-tip sequence; use the Data tab or the Mac menu and ribbon controls. Keyboard shortcuts can vary with language, ribbon customization, and version, so the visible command is the dependable option.
Sort by two or more numeric columns
Multi-level sorting orders records by a primary number and then uses another column to resolve ties. In the Sort dialog, choose the primary field and order, then select Add Level to add the next field. For instance, a service table could sort first by Department in a separate text-based level, then by Hours from largest to smallest. For a numeric-only example, a product table can sort by Units Sold descending and, among products with equal unit counts, by Revenue descending.
Each level applies only when values in the preceding level tie. If two products have different unit counts, the Revenue level does not change their order. To change priority, use the move up and move down controls in the dialog. This is more reliable than sorting one column, then sorting another independently: a later single-column sort can disrupt the earlier grouping if it is not applied as another level in the same sort operation.
When you need repeatable rules, give the fields clear headers and use the dialog rather than relying on whichever cell happens to be active. Before confirming, review the listed levels and their directions. A mistaken ascending direction on the primary field can make the entire result look wrong even if the secondary sort is correct.
Sort a table, filtered list, or selected range
Excel tables, created with Insert > Table or Home > Format as Table, include filter arrows in their header row. Open the arrow for a numeric column and choose the ascending or descending sort command. The table sorts its rows together and keeps the header in place. This is a convenient option for regularly updated lists because the table can expand as new records are added.
A normal range can also be sorted while a filter is active. Sorting a filtered column orders the displayed records by that field; rows hidden by the filter remain hidden. Clear or adjust the filter if the goal is to inspect the complete dataset. Avoid sorting only visible cells by making an isolated selection unless you specifically intend to rearrange only that selection; partial-range sorting can make a worksheet difficult to interpret.
Excel for the web has sorting commands in its ribbon and table header menus, but some dialog options and interface details can differ from desktop Excel. Excel for Mac also supports sorting through the Data tab, though the ribbon and menu organization may not match Windows exactly. If an instruction refers to a Windows-only key-tip sequence, use the on-screen sort command on Mac or in the web app instead.
Numbers stored as text and other common problems
A frequent cause of an apparently incorrect sort is that some entries are numbers stored as text. Text values may sort differently from actual numbers. For instance, a text value of 100 can be placed before a text value of 20 because text sorting considers characters rather than numeric magnitude. A column can contain a mixture of true numbers and text-number entries, making the order especially confusing.
To check a suspicious cell, select it and look at the formula bar and number format; also compare how it aligns with other values, while remembering that alignment can be changed manually. A warning icon may offer Convert to Number when Excel detects a text-number value. You can also use Data > Text to Columns and complete the wizard to convert suitable text entries, or use a controlled conversion in a helper column. Check the results before replacing the original data, especially when leading zeros are meaningful, as with postal codes or product IDs.
Other causes of surprising results include:
- Numbers contain units or symbols as text. Entries such as 12 kg or $30 may not behave as plain numeric values if the characters are part of the cell contents rather than number formatting.
- Some values are blank. Blanks can appear together at one end of a sorted range. Decide whether blank records should remain in the sort or be removed through a filter.
- The sort range is incomplete. A blank row or column can make Excel treat part of a list as a separate block. Select the complete data range and inspect the selection before sorting.
- A header is included as data. In the Sort dialog, enable My data has headers when appropriate.
- Only one column moved. Undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then repeat the sort and expand the selection.
Dates can cause a related issue. Excel stores real dates as serial numbers, so they sort chronologically when they are recognized as dates. Dates typed as inconsistent text may sort alphabetically instead. Verify the values are actual dates before relying on a date sort; changing a cell’s display format alone does not necessarily convert text into a date value.
Choose a sort method for repeat use
For a one-time rearrangement, the ribbon buttons or a table header menu are fastest. Use the Sort dialog when you need a particular field, multiple levels, or a clear header setting. If the original data order matters, save a copy or add an index column before sorting. An index such as 1, 2, 3, and so on lets you restore the original sequence later by sorting on that index.
If you need a sorted view that updates without rearranging the source data, a formula can be a better fit. With numbers in cells A2:A8 containing 12, 4, 19, 7, 4, 31, and 10, enter =SORT(A2:A8,1,1) in an empty cell. In Microsoft 365 or Excel 2021 and later, the result spills into adjacent cells in ascending order as 4, 4, 7, 10, 12, 19, and 31. The two 4s remain because SORT does not remove duplicates. Keep the spill area clear; occupied cells can prevent the result from appearing. Excel for the web supports modern dynamic-array formulas, though availability depends on the account and app version.
A formula-based sorted view is not the same as physically sorting a table. The formula result updates as its source changes, while a ribbon sort changes the row order in the source range. For workbooks that must be opened in older Excel versions, ordinary sorting is generally more compatible than newer dynamic-array functions. Choose based on whether you need an editable reordered list or a separate live display.
Frequently Asked Questions
How do I sort numbers from highest to lowest in Excel?
Select a cell in the number column and choose Data > Sort Largest to Smallest. If the values belong to records in other columns, expand the selection so each complete row moves together.
Why is Excel sorting 100 before 20?
One or both entries may be stored as text. Convert text-number entries to real numbers, then sort again. Be cautious with identifiers that use leading zeros, since converting them to numbers can remove those zeros.
How do I sort a number column without mixing up the rows?
Sort the full data range or use a table header sort. When Excel asks whether to expand the selection, choose Expand the selection. Confirm that each name or record still appears beside its original number.
Can I sort by more than one number column?
Yes. Choose Data > Sort, set the first column and direction, then select Add Level for the next column. The additional level orders records only when the earlier sort values are tied.
Can Excel sort numbers automatically when I add a new row?
A normal ribbon sort does not necessarily keep a range continuously sorted as new values are entered. Sort the table again when needed, or use a separate dynamic-array formula such as SORT in a supported version of Excel to display an updating sorted view.
Does sorting change the numbers themselves?
No. Sorting changes the position of rows or cells in the selected range, not the numeric value stored in each cell. To preserve relationships between fields, sort complete records rather than an isolated column.
Related
- Excel SUM Divided by Count: Calculate an Average
- Excel Sum by Color: How to Total Cells by Fill Color
- Excel Sum by Cell Color: Methods That Actually Work
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel PivotChart: How to Count Unique ValuesYes. In Excel for Microsoft 365 on Windows, you can count unique values in a PivotChart by building…
- Find Years of Service in Excel with a Simple FormulaTo calculate completed years of service in Excel, put each employee’s hire date in B2 and enter =DATEDIF(B2,TODAY(),"y")…
- Excel Sort Examples: Rows, Text, Dates, and Custom ListsTo sort a worksheet in Excel for Microsoft 365 on Windows, select a cell in the data, then…
- Power Query If Function: Syntax, Examples, and TipsPower Query’s if is a conditional expression, not a function: write if condition then value_if_true else value_if_false. For…
- Excel Formula Bar Disappeared? How to Show It AgainIf the Excel formula bar disappeared, turn it back on from View > Show > Formula Bar in…
- Excel NPV Calculation: Steps, Formula, and ExamplesTo calculate NPV in Excel, put the discount rate in one cell, list future cash flows in period…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.