To sort data in an Excel table, click a cell in the column you want to sort, then choose Data > Sort & Filter > Sort A to Z or Sort Z to A on the Windows ribbon. You can also use the arrow in a table header to choose a sort order. Excel rearranges complete table rows, keeping each record’s values together.
For more control—such as sorting by several columns, dates, colors, or a custom sequence—use the Sort dialog. The key is to sort the table as a table, rather than sorting one column of cells by itself.
How sorting works in an Excel table
An Excel table is a structured range with a header row and built-in features such as filter arrows. Sorting changes the order of the table’s data rows; it does not change the underlying values or delete records. When you sort a table by a field such as City, Excel moves each entire row so the city remains matched with the right person, date, or amount.
A sort is different from filtering. Sorting changes the visible order of records, while filtering temporarily hides records that do not meet selected conditions. You can sort a filtered table, but the sort only changes the order of the records that remain visible; hidden records are still part of the table and can reappear when you clear the filter.
Sorting also does not normally create a permanent, automatic order. If you add a new row later, Excel may place it at the end of the table rather than in its sorted position. Apply the sort again when you need the updated table in order.
Sort a table by one column
For a quick ascending or descending sort, use the header arrow or the Data tab. First, make sure the data is in an Excel table: click inside it and look for the Table Design tab. If it is an ordinary range, select a cell in the data and choose Insert > Table, confirm that the range is correct, and check My table has headers if the first row contains field names.
- Click the filter arrow in the header of the column you want to sort.
- Choose the relevant ascending or descending command, such as Sort A to Z, Sort Z to A, Sort Smallest to Largest, or Sort Newest to Oldest.
- Check the result to confirm that the rows are in the intended order.
You can also click a cell in that column and select Data > Sort A to Z or Data > Sort Z to A. The wording changes according to the data type. Excel treats numbers, text, and dates according to their values, not just how they look on screen. In Microsoft 365 for Mac, the corresponding sorting controls are on the Data tab; header-arrow sorting is also available. Ribbon layout can vary with window size and version.
Sort by multiple columns
A multi-level sort is useful when the first field contains repeated values. For example, a staff list could be sorted first by Department and then by Last Name, so departments stay grouped and employees within each department appear alphabetically. A sales table could be sorted by Region, then by Salesperson, and finally by Order Date.
- Click a cell in the table and choose Data > Sort & Filter > Sort.
- In the Sort dialog, check My data has headers if the top row contains column names.
- In Sort by, choose the first column and select its sort order.
- Choose Add Level, then select the next column and order. Add further levels if needed.
- Use the level move controls to put the most important sort first, then click OK.
Excel applies the first level as the primary order. It uses the second level only to arrange rows that tie on the first, and later levels break remaining ties. If you reverse the levels, the result can be substantially different. In the staff example, sorting Last Name first and Department second groups all employees alphabetically across the whole table, rather than grouping departments first.
Choose the right sort order
Ascending and descending are not the only choices. In the Sort dialog, the Sort On field can sort by cell values, cell color, font color, or conditional-formatting icon where those options apply. This helps when color or an icon represents a status, but it does not infer what the formatting means. You must specify the color or icon and whether it should appear on top or at the bottom.
Custom lists let you order text according to a meaningful sequence rather than alphabetically. For example, the months January through December or priority labels such as High, Medium, and Low may need a particular order. In the Sort dialog, select the column, choose Custom List in the order options, and select or enter the sequence. This is different from creating a filter: a custom list controls sorting order and does not hide any items.
For dates, choose oldest-to-newest or newest-to-oldest. For numerical values, choose smallest-to-largest or largest-to-smallest. If the results look wrong, check whether the entries are truly stored as dates or numbers. Text that looks like a number may be sorted alphabetically, so values such as 100 can appear before 20. Mixed data types in one column can also produce an unexpected-looking order.
Keep records intact and protect headers
The most important precaution is not to sort just one column of a multi-column record. If Excel asks whether to Expand the selection or Continue with the current selection, choose Expand the selection so related fields move together. Better still, convert the full dataset to a table and sort using its header controls. Sorting only one column can detach names from their addresses, or products from their prices.
A table’s header row is treated as labels, not ordinary data. When using the Sort dialog on a regular range, confirm that My data has headers is selected when appropriate; otherwise, the first row may be included in the sort. Also verify that the selected table includes every intended record and field. A blank row or column separating data can cause Excel to treat part of a dataset as a separate range.
Before a substantial reordering, consider saving the workbook or duplicating the worksheet if you may need to recover the original order. Excel generally has Undo, but subsequent edits can make it harder to return to the exact prior state. If the original sequence matters, add a clearly named sequence-number column before sorting, then sort that column later to restore the earlier order.
Common sorting problems and fixes
- Numbers sort like text: Check whether some entries are stored as text, often indicated by inconsistent alignment or a warning marker. Convert the affected values to numbers, then sort again. Do not convert codes with meaningful leading zeros, such as postal codes, unless that is appropriate for the data.
- Dates appear out of order: Some apparent dates may be text strings, or the column may contain mixed formats. Ensure the entries are valid Excel dates and apply a consistent number format. Changing a display format alone does not always convert text into real dates.
- Some rows seem to be missing: A filter may be hiding rows. Clear the filter using the header dropdown or the Data tab, then review the complete table.
- Only part of the data moved: The range may not be an Excel table, or Excel may have been told to continue with the current selection. Undo immediately if possible, select the entire dataset, and sort again with the full record range included.
- New rows are not in order: Adding records does not necessarily reapply the current sort. Run the sort again after adding or changing data.
- Blank entries are scattered: Blank cells can affect how the result appears, especially in multi-level sorts. Decide whether blanks should remain, be filled, or be reviewed separately before sorting.
If a sort seems to ignore spaces or punctuation, inspect the actual cell values for leading or trailing spaces and inconsistent spelling. Two labels that look almost identical may be different text. Correcting the source values is usually more reliable than trying to compensate for inconsistent data with additional sort levels.
Table sorting compared with other options
Sorting a table with its header dropdown is the simplest choice for a quick, single-column sort. The Data tab’s Sort dialog is better for multi-level rules, custom lists, and formatting-based orders. For an ordinary range, the Sort dialog can still be used, but selection and header settings matter more because the range does not have the same built-in table structure.
Excel also has worksheet-level sorting tools, but a table is generally easier to manage when records have clear headers and grow over time. A separate formula-based sorted view can be useful when the source order must remain untouched, but dynamic array formulas such as SORT are available only in Microsoft 365 and Excel 2021 or later. They create a sorted result elsewhere rather than rearranging the source table. Use table sorting when you intend to change the record order in place; use a separate view when preserving the source order is important.
Frequently Asked Questions
How do I sort an Excel table alphabetically?
Click the arrow in the text column’s header and choose Sort A to Z. To reverse the order, choose Sort Z to A. Excel moves complete table rows, not just the text in that column.
Can I sort an Excel table by two columns?
Yes. Open Data > Sort & Filter > Sort, choose the primary column, click Add Level, and set the second column. The first level groups the main categories; the next level orders records within each group.
Why does Excel sort 100 before 20?
The values may be stored as text rather than numbers. Text sorts by character sequence, whereas numeric values sort by magnitude. Convert entries that should be numbers, while preserving text codes such as identifiers that need leading zeros.
Does sorting a table change the formulas?
Sorting moves formula cells with their rows. Excel adjusts relative references as appropriate, and formulas that use table column names can be easier to interpret. Review formulas that depend on row position or a particular order, because changing row order can affect what those formulas mean.
How do I return a table to its original order?
If you have not made other changes since sorting, use Undo. Otherwise, you need a saved copy or a sequence-number column that recorded the original row order. Excel does not keep a built-in permanent history of every prior sort order.
Related
- Excel Searchable Slicers: Find Items in Large Lists
- Excel Scatter Plot With Two Y-Axes: How to Make One
- Excel Scatter Plot Vertical Line: Add One and Format It
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Set Out of Office in Outlook on Your DevicesTo set an out-of-office message in Outlook, open Automatic Replies, switch them on, write your message, and—if you…
- Excel Find and Replace: How to Search and Change DataIn Excel for Microsoft 365 on Windows, press Ctrl+H, enter the text to find and its replacement, then…
- Excel Historical Sales Analysis: Find Trends and PatternsTo analyze historical sales in Excel, organize transactions by date, summarize sales by month or another consistent period,…
- Sync a Budget Spreadsheet Across Devices and Teams SafelyTo sync a budget spreadsheet in Excel for Microsoft 365, save the workbook to OneDrive, then open that…
- How to Make a Color Key in Excel for Clearer SheetsTo make a color key in Excel, set aside a small area of the worksheet, add a labeled…
- How to Import an Excel Table Into Word and Keep It UpdatedTo import an Excel table into Word, select and copy the cells in Excel, then paste them into…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.