To sort data in Excel, select a cell in the list, open Data > Sort, choose the column and order, then select OK. For a quick one-column sort, use Data > Sort A to Z or Data > Sort Z to A; make sure Excel includes every related column so each record stays together.
What sorting does in Excel
Sorting changes the order of rows according to values in one or more columns. For example, a customer list can be arranged by last name, a sales report by revenue, or a schedule by date. The values themselves are not changed; the rows are rearranged so that records appear in the selected order.
Excel recognizes different kinds of sort order. Text can go alphabetically from A to Z or in reverse; numbers can go smallest to largest or largest to smallest; and dates can go oldest to newest or newest to oldest. Excel also offers sorting by cell color, font color, and conditional-formatting icon in the desktop Sort dialog.
Sorting is different from filtering. A sort changes the sequence of records, while a filter hides records that do not meet selected criteria. You can sort a filtered list, but sorting does not itself remove or hide any data.
Prepare the data before sorting
Before sorting, check that the information forms a consistent table: each column should have a heading, and each row should represent one complete record. A blank row or column inside the list can make Excel treat part of the data as a separate region. If you select only one column, Excel may ask whether to expand the selection. Choose Expand the selection to move the related row values with it.
For a list you will update regularly, convert the range to an Excel table with Home > Format as Table, choose a style, and confirm whether the table has headers. Tables make it easier to identify the data boundaries and provide filter and sort controls in their header cells. A table sort reorders whole records, not just the values in the column whose header you clicked.
- Use one clear header per column, such as Date, Product, or Amount.
- Keep the same kind of value in each column. Avoid mixing dates, explanatory text, and numbers in a single field.
- Remove completely blank rows from the middle of a list, or select the full intended range before sorting.
- Check that each row contains the correct related values before proceeding.
Sort by one column
For a quick sort, click a cell in the column you want to use as the key. On the Windows desktop version of Microsoft Excel for Microsoft 365, select Data > Sort A to Z for ascending order or Data > Sort Z to A for descending order. Excel normally detects the surrounding list and moves each full row with the selected column.
For more control, select a cell in the data and open Data > Sort. In the dialog, choose the column under Sort by, select what to sort on (usually Cell Values), and choose an order such as A to Z or Largest to Smallest. If your first row contains headings, make sure My data has headers is selected so Excel does not sort the headings among the records. Select OK to apply the sort.
For example, in a table with columns for Item and Units, sorting Units from largest to smallest puts the highest-quantity item first. The Item value remains on the same row as its Units value because Excel sorts the records as a group.
Sort by multiple columns
Use a multi-level sort when one column is not enough to give the order you want. For example, a roster might need to be grouped by Department and then ordered alphabetically by Last Name within each department. Open Data > Sort, choose Department in the first level, then select Add Level and choose Last Name for the next level.
Excel applies the first level as the main sort and uses later levels to order records that tie at earlier levels. In the roster example, all Marketing records appear together, all Sales records appear together, and names are sorted within each group. To prioritize a different field, select its level and use the up or down controls in the dialog to change its position. Choose OK when the levels and their orders are correct.
Multi-level sorting is useful for reports such as region, salesperson, and then sales amount. If the amount should be highest first within each salesperson, set Region as the first level, Salesperson as the second, and Amount as the third with a descending order. The order of levels matters: putting Amount first would group the entire list by amount before considering region or salesperson.
Use custom orders and sort by color
Alphabetical order is not always the order a list needs. A priority column, for instance, may need to appear as High, Medium, Low rather than alphabetically. In the desktop Sort dialog, set the column under Sort by, then open the Order menu and choose Custom List. Select an available list or enter the sequence you need, then confirm it. Excel includes familiar sequences such as days of the week and months; a custom sequence is helpful for categories that have a meaningful business order.
To group records by formatting, select Cell Color, Font Color, or Cell Icon in the Sort On field. Then specify which color or icon should appear at the top or bottom. This can help bring highlighted items together, but it is usually clearer to sort by an explicit status or category column when one is available. Formatting can be changed or removed, so it is a less durable way to represent important information.
For unusual text rules, the Sort dialog also has an option to sort case-sensitively. This is rarely necessary for everyday lists, but it can matter when uppercase and lowercase entries should be treated as distinct. Check the dialog’s Options settings if the case distinction is important.
Sort with the SORT function
Sorting through the ribbon rearranges the source data. Excel also has a SORT function that returns a sorted copy of a range in a separate spill area, leaving the original range in place. This is useful for a live report that should update when source values change. The function is available in Microsoft 365 and Excel 2021 or later; it is not available in every older Excel release.
With item names in A2:A5 and quantities in B2:B5, where the rows are Pears and 8, Apples and 3, Oranges and 6, and Plums and 2, enter =SORT(A2:B5,2,1) in an empty cell. The result spills into two columns in ascending order by the second column: Plums, 2; Apples, 3; Oranges, 6; Pears, 8. The 2 tells Excel to sort by the second column of the selected range, and 1 requests ascending order. The calculation is a sort, not arithmetic; the quantities remain unchanged.
Leave enough empty cells below and to the right of the formula for the result. If another value blocks the spill area, Excel returns a spill error rather than overwriting that value. Use the ribbon sort when the original records themselves must be rearranged, and use SORT when you want a separate, automatically updated sorted view.
Common sorting problems and how to fix them
- Rows no longer match: This can happen if only one column was sorted. Undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then select the full data range and sort again. If Excel asks whether to expand the selection, choose that option.
- Numbers appear in an unexpected order: Some values may be stored as text, especially after copying data from another system. Text values can sort differently from true numbers. Check for warning indicators or inconsistent number formats, convert the affected cells to numbers, and sort again.
- Dates do not sort chronologically: Dates stored as text may not behave like real Excel dates. Confirm that the cells contain date values rather than text that merely looks like a date. A consistent date format can make the values easier to inspect, but changing display format alone does not convert text into dates.
- Headings move into the list: In Data > Sort, select My data has headers. Also check that the intended header row is included in the selection.
- Some records are left out: A blank row or an incomplete selection may have divided the data. Select the full range explicitly or turn it into a table before sorting.
- Excel refuses to sort: Merged cells in the selected range can interfere with sorting. Unmerge them and use ordinary cells with a consistent layout. Also check whether the worksheet is protected and whether the selected range includes a shape or other unsupported content.
If a sort produces an unexpected result, avoid making more edits before using Undo. On Windows the shortcut is Ctrl+Z; on Mac it is Command+Z. Undo restores the previous arrangement, after which you can inspect the selected range and sort settings. If you have already made further changes, restoring the original order may require a backup or a separate original copy.
Excel on Mac and Excel for the web
The core approach is similar across Excel for Microsoft 365 on Windows, Excel for Mac, and Excel for the web: select a value in the data and use the sort commands on the Data tab, or use a table header’s sort menu. Ribbon layout and some dialog details can vary by platform or update. On Mac, the Data tab provides ascending, descending, and custom sort controls; use the full sort dialog when you need multiple levels or a more specific order.
Excel for the web also supports common ascending, descending, and custom sorts, but some advanced controls can differ from the desktop app. If you cannot find a particular option, open the workbook in the desktop version and use Data > Sort. Regardless of platform, verify the selection and header setting before applying a sort, especially when the worksheet contains several neighboring data blocks.
Frequently Asked Questions
How do I sort alphabetically in Excel?
Select a cell in the text column and choose Data > Sort A to Z. Use Data > Sort Z to A for reverse alphabetical order. Check that Excel sorts the full records rather than only the selected column.
How do I sort by date from oldest to newest?
Select a cell in the date column and use the ascending sort command, or open Data > Sort and choose Oldest to Newest. If the result is not chronological, some entries may be text rather than actual Excel date values.
Can I sort by two columns in Excel?
Yes. Open Data > Sort, set the primary column, choose Add Level, and select the secondary column. Excel sorts by the first level, then uses the next level to order records tied at the first.
How do I keep a header row from being sorted?
In the Sort dialog, select My data has headers. In a formatted Excel table, use the column header’s sort menu. If a heading is included as an ordinary data row, confirm the header setting before applying the sort.
Does sorting in Excel change the original data?
A ribbon sort rearranges the original rows. The SORT function instead displays a sorted result in another area and leaves the source range unchanged. Choose based on whether you want to reorganize the source or create a separate sorted view.
Related
- Room List Template Excel: How to Build and Use One
- Resource List Excel Template: Set Up, Track, and Share
- Replace in Excel: Find and Replace Text, Values, and More
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- AVERAGE vs AVERAGEIF in Excel: Which Should You Use?Use AVERAGE to find the mean of numeric values in a range; use AVERAGEIF to average only values…
- Excel PV Factor Formula: Calculate Present ValueIn Excel, calculate a single-payment present value factor by dividing 1 by 1 plus the discount rate raised…
- Excel Formula List A to Z: Functions and Examples GuideAn Excel formula is an expression that begins with an equals sign; most formulas use functions such as…
- Excel Formula to Add Dates in SequenceTo add dates in sequence in Excel, enter a starting date in A2, then enter =A2+1 in A3…
- Excel Formula for Adding Days to a Date: ExamplesTo add days to a date in Excel, add the number of days to the date cell: with…
- Power Query IF Examples: Conditional Logic in ExcelIn Power Query, write an IF test in M as if condition then value_if_true else value_if_false. For example,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.