To sort in Microsoft Excel for Microsoft 365 on Windows, click a cell in your data, then choose Data > Sort A to Z or Data > Sort Z to A for a quick sort. For multiple columns or custom settings, choose Data > Sort. Sorting rearranges records into an order you choose; first make sure each record’s details are on the same row and that your data has clear column headings.
What You’ll Need
- An Excel workbook containing the data you want to organize.
- A continuous table or range with one type of information per column, such as names, dates, or amounts.
- Column headings, if available. They make it easier to choose the right sort field and prevent the headings from being mixed into the records.
Step-by-Step
- Check the layout before sorting. Each row should represent one complete record, and each column should contain one kind of value. For example, a list of orders might have headings for Order Date, Customer, City, and Total, with each order’s details in the same row. Remove completely blank rows or columns inside the data if they split it into separate blocks. If the workbook is important, save a copy first so you can return to the original order if needed.
- Choose the data to sort. Click any cell inside a continuous data range. Excel usually recognizes the surrounding rows and columns as one block. You can select a specific range if necessary, but include every column that belongs to the records. If you select only the Customer column while the order details are in neighboring columns, the names may move without their corresponding order information. When working with an Excel table, click any cell in the table; its header filters and table range help keep the records together.
- Apply a quick ascending or descending sort. On the ribbon, open the Data tab. Select a cell in the column you want to sort, then click Sort A to Z for ascending order or Sort Z to A for descending order. For text, ascending generally means A to Z; for numbers it means smallest to largest; for dates it means earliest to latest. The descending command reverses those orders. Excel sorts the related rows along with the selected column when it detects a connected data range.
- Use the Sort dialog for more control. Click inside the data and choose Data > Sort. In the dialog, check My data has headers if the first row contains headings. Under Sort by, select the column you want to order. Keep Sort On set to Cell Values for a normal data sort, then choose the order, such as A to Z, Smallest to Largest, or Oldest to Newest. Click OK to apply it. If the heading is not recognized, confirm that the header checkbox is set correctly before choosing the field.
- Sort by more than one column. In the Sort dialog, set the first priority under Sort by, then click Add Level. Choose the next column under Then by and set its order. For example, sort a staff list first by Department A to Z, then by Last Name A to Z. Excel groups the rows by department and alphabetizes names within each group. Add another level if records still need a further order, such as sorting equal last names by first name. Use the up and down arrows in the dialog to change which level takes priority.
- Sort by cell color, font color, or icon if needed. Open Data > Sort, select the relevant column, and change Sort On from Cell Values to the available formatting option, such as Cell Color. Choose the color and whether it should appear on top or at the bottom. Add levels to place different colors in a chosen sequence. This is useful when color or conditional-formatting icons mark a status, but check that the formatting is applied consistently before relying on it.
- Confirm the result and save. Scan a few records at the top, middle, and bottom to verify that values are in the intended order and that each row’s fields still belong together. If the order is wrong, use Ctrl+Z on Windows immediately to undo the sort, then repeat it with the correct column or range. Save the workbook after confirming the result. Undo may no longer be available after closing the file or performing other actions.
In Excel for Mac, the basic process is similar: use the Data tab for sorting, and open the Sort dialog for multiple levels or other options. Ribbon layout and some shortcut keys differ from Windows. Excel for the web also offers basic ascending and descending sorting from the Data tab; advanced dialog choices can vary by current web interface, so use the available Sort controls and check the result before continuing.
Common Mistakes
- Sorting only one column. Selecting a single column and choosing a sort can trigger a warning asking whether to expand the selection. Choose Expand the selection when the neighboring columns are part of the same records. Choosing to continue with the current selection can separate names, dates, or amounts from their original rows.
- Including a heading as a record. If the header row is sorted into the data, the dialog may not be set to My data has headers. Conversely, checking that option when there is no header can cause the first actual record to be left out of the sort. Set the checkbox to match the range.
- Leaving blank rows or columns in the middle. A completely empty row or column can make Excel interpret a dataset as separate regions. Remove the gap or carefully select the full intended range before sorting. Do not delete a blank row if it is intentionally separating different datasets; sort each dataset separately.
- Assuming numbers or dates stored as text will sort normally. Values that look numeric but are stored as text may sort alphabetically, so 100 can appear before 20. Dates stored as text can also appear in an unexpected order. Check the cell format and whether values are consistently recognized as numbers or dates.
- Expecting a sort to preserve the previous order automatically. Sorting changes row order. If the original sequence matters, add a temporary column with sequence numbers before sorting, or keep an untouched copy of the data.
Tips
- Convert a regular range to a table for ongoing lists. Select a cell in the data and choose Insert > Table, confirming whether the table has headers. Tables provide filter arrows in the heading row and generally include new adjacent records when you work with the list. They also make it easier to repeat a sort from a column heading.
- Use a custom order when alphabetic order is not useful. For values such as High, Medium, and Low, open Data > Sort, choose the column, and select Custom List in the order options if it is available. Choose an existing list or create the desired sequence in the Custom Lists settings. The exact settings route can vary by Excel build; on Windows, custom lists are managed through File > Options > Advanced. Test the result if values include spelling variations.
- Use filters when you want to view part of the list. Sorting changes the order of records, while filtering hides records that do not meet your criteria. For a table, use the arrow in a heading to sort or filter that column. You can filter first and sort the visible records, but be aware that the sort applies within the data range and does not delete hidden records.
- Decide whether a sort should read rows or columns. Normal sorts order records from top to bottom. If you genuinely need to sort values across columns, open Data > Sort > Options and choose Sort left to right. This is intended for layouts where each column is a unit to be rearranged; it is not the usual choice for a list of records.
- Keep field names simple and unique. Distinct headings such as Start Date and End Date make it less likely you will choose the wrong sort column. Avoid merged cells within the data range, because they can interfere with sorting and selecting a consistent block.
Troubleshooting
- Rows became mismatched after sorting: Undo at once with Ctrl+Z on Windows, or use the Undo command on Mac. Redo the operation by selecting a cell in the data and choosing the sort command, or accept Expand the selection if Excel prompts you. If you already made other changes and cannot undo, restore a saved copy or use a backup; do not try to manually repair a large dataset without checking each record.
- The order looks wrong for numbers: Check whether values are numbers or text. A small green triangle may indicate a number stored as text, though its display depends on Excel settings. You can use the warning menu to convert recognized values to numbers, or use Data > Text to Columns to convert consistently formatted text where appropriate. Review the selected column first, because conversion can change identifiers that legitimately contain leading zeros.
- Dates sort alphabetically or into unexpected groups: Check for mixed date formats, text entries, or blanks. Apply a consistent date format and ensure the entries are real Excel dates, not text that only looks like dates. Formatting alone changes how a valid date displays; it does not necessarily convert text into a date value. Test a few cells by changing the number format or inspecting their alignment and behavior.
- A heading appears in the sorted records: Open Data > Sort and set My data has headers correctly. Make sure the selected range starts at the actual heading row, not at a title above the table. A worksheet title or explanatory note should usually be outside the sortable range.
- Some rows did not move: Look for blank rows or columns separating the list, or for cells outside the selected range. Select the full range including every related field, then sort again. Also check whether a filter is active; a funnel or filter indicator in a heading can mean some records are hidden from view.
- The sort command is unavailable or the dialog behaves unexpectedly: Check whether the worksheet is protected, whether you are editing a cell, and whether multiple worksheets are selected. Finish cell editing with Enter or Esc, ungroup selected sheets if necessary, and check protection settings. In a shared or web workbook, confirm you have permission to edit and that another feature is not restricting changes.
Frequently Asked Questions
How do I sort a column without separating its rows?
Click a cell in the column and use the sort command. If Excel asks whether to expand the selection, choose Expand the selection so related cells in each record move together. Never sort just one field when neighboring columns belong to the same records.
Can I sort by two columns in Excel?
Yes. Choose Data > Sort, select the first column, click Add Level, and choose the second column under Then by. The first level has priority; the second orders records that tie on the first.
How do I sort a list by month or weekday?
Use a custom list when the values are month names or weekday names, so Excel follows calendar order rather than ordinary alphabetical order. In the Sort dialog, select Custom List for the order and choose the built-in list if offered. For actual date values, use the normal oldest-to-newest sort.
Can I undo a sort?
Usually, yes. Use Ctrl+Z on Windows immediately after the sort, or click Undo. If you have closed the workbook or made later changes that displaced the sort in the undo history, reopen a saved copy or restore a backup if one is available.
Does sorting change the original data permanently?
Sorting rearranges the data in the workbook; it does not create a separate sorted copy. Save a duplicate sheet or workbook first if you need to preserve the original sequence. A table sort also changes the row order in that table.
Why does Excel sort 100 before 20?
The values may be stored as text, in which case Excel can compare characters rather than numeric value. Convert the entries to real numbers if they are meant to be quantities, while preserving text identifiers such as product codes or account numbers that may need leading zeros.
Related
- How to Repair an Excel File in Windows 11
- How to Repair Excel Desktop App: Windows Steps and Fixes
- Rename a Sheet in Excel Without a Mouse
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Sort Shortcut: Sort Your Data Quickly and SafelyIn Excel for Microsoft 365 on Windows, press Alt, A, S, S in sequence to open the Sort…
- Excel Accounting Formulas Cheat Sheet for Daily BooksAn Excel accounting formulas cheat sheet starts with =SUM(range) for totals, a simple addition formula for running balances,…
- Excel IFERROR Function: Syntax, Examples, and TipsMicrosoft Excel’s IFERROR function returns a value you choose when a formula produces an error; otherwise, it returns…
- Sort Dates in Excel by Month and Day, Not the YearTo sort dates in Excel by month and day while ignoring the year, add a helper column with…
- Average in Excel: Formula, Examples, and Common FixesTo calculate an average in Excel, use the AVERAGE function: with numbers in B2:B10, enter =AVERAGE(B2:B10). Excel returns…
- How to Filter A-Z in Excel: Sort a List the Right WayTo put Excel entries in alphabetical order, select a cell in the column and choose Home > Sort…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.