Excel Data Sorting: Sort Rows, Columns, and Lists Correctly

Formulas & functions · Updated November 18, 2026

To sort data in Excel for Microsoft 365 on Windows, click a cell in the column you want to sort, then choose Data > Sort A to Z or Data > Sort Z to A. Excel will usually sort the whole connected data range, keeping each row together; for multiple sorting rules, choose Data > Sort and add levels in the Sort dialog.

What sorting does in Excel

Sorting rearranges records according to values in one or more columns. A record is usually a row: for example, one row might contain a customer name, city, order date, and total. Sorting the City column alphabetically should move the entire row, not just the city cell. This preserves the relationship between fields.

Excel can order text alphabetically or in reverse, numbers from smallest to largest or largest to smallest, and dates from oldest to newest or newest to oldest. It can also sort by cell or font color, icon, and a custom order such as High, Medium, Low. Sorting changes the displayed order of the records; it does not calculate a ranking or remove duplicate entries.

A common misconception is that selecting one column and sorting it is always harmless. If Excel detects adjacent data, it normally offers to expand the selection so all related columns move together. If you choose to continue with only the selected column, names, dates, and other values in the same records can become mismatched. For that reason, sorting a complete table or range is safer than sorting a lone field.

Prepare the data before sorting

A clean layout makes Excel’s decisions more predictable. Keep one field per column, put a clear header in the first row, and avoid blank rows or blank columns inside the dataset. Do not merge cells within the data range: merged cells can prevent a sort or make the range behave unexpectedly. Blank rows used as visual separators are better replaced with formatting or filters.

  • Check that every record has the same set of fields and that the header labels are unique and meaningful.
  • Look for stray spaces, inconsistent spelling, and values that appear to be numbers or dates but are stored as text.
  • Save a copy or use Undo promptly if a sort produces an unexpected result. Sorting is not a substitute for a backup.
  • If you have totals or notes below the list, leave a blank row between them and the data, or convert the data itself to an Excel table.

Before sorting a range, click inside it rather than selecting a single column. Excel generally recognizes a contiguous block around the active cell. When the selection prompt appears, choose Expand the selection to keep records intact. If the data has gaps or nearby unrelated content, inspect the highlighted range rather than assuming Excel identified the intended boundary.

Sort a list by one column

For a straightforward sort, click any data cell in the target column. On the Data tab, choose Sort A to Z for ascending order or Sort Z to A for descending order. The labels may be shown as smallest to largest or largest to smallest for numeric data, and oldest to newest or newest to oldest for dates. If Excel asks whether to expand the selection, select that option and confirm.

For example, with a customer list containing Name, Region, and Order Date, clicking a Region cell and sorting A to Z arranges the regions alphabetically while moving each customer’s name and date with the correct record. If the list has a header row, Excel often recognizes it automatically. Check that the header remains at the top after sorting; if it is treated as a record, undo and use the Sort dialog’s header setting.

To control the sort explicitly, choose Data > Sort. In the dialog, select the column under Sort by, choose the sort basis—usually Cell Values—and set the order. Confirm that My data has headers is selected when the first row contains field names. Click OK to apply the sort.

Sort by multiple columns

Use a multi-level sort when one field is not enough to create the order you want. In Data > Sort, set the first rule, then click Add Level to add another. Excel applies the first level first; it uses the next level to order records that tie on the first field, and later levels resolve any remaining ties.

For instance, to list staff by department and then by last name, set Department as the first level in A to Z order, add Last Name as the second level, and confirm that the headers are recognized. Everyone in each department will be grouped together, with names alphabetized within that group. A third level such as First Name can help distinguish employees who share a last name.

The order of levels matters. Sorting first by last name and then by department will group people by surname, not department. In the Sort dialog, use the move-up and move-down controls to adjust a level’s priority. If you need a different sequence later, reopening the dialog makes the current sort rules visible and editable.

Sort Excel tables and filtered lists

Converting a well-formed range to an Excel table is useful when records will grow or be edited regularly. Select a cell in the range and choose Insert > Table, confirm the range, and indicate whether it has headers. Tables add filter arrows to header cells; selecting an arrow gives sorting and filtering options for that field. When you add records directly below a table, Excel can extend the table so its columns remain part of the same dataset.

Sorting and filtering are different. Sorting changes the order of records, while filtering temporarily hides records that do not meet chosen conditions. A filtered list can still be sorted, and the hidden rows remain part of the data. When checking a result, remember that a filter may be hiding records rather than deleting them. Clear the filter to see the full list again.

In Excel for Mac, the Data tab and the main sort options are available, though ribbon layout and dialog details can vary slightly by release. Excel for the web also supports basic sorting and table filter menus; some advanced dialog options may differ from the Windows desktop version. If a command is not visible, check the Data tab or the dropdown in the relevant table header.

Sort by color or a custom order

When color or symbols carry meaning in a worksheet, the Sort dialog can put those cells together. Choose Data > Sort, select the relevant column, and choose Cell Color, Font Color, or Cell Icon in the sort-basis menu when that option is available. Select the color or icon and choose whether it should appear on top or at the bottom. Add further levels if you also need a secondary order.

Color sorting is useful for organizing manually highlighted exceptions, but color alone is not a reliable data field. A cell’s fill might be changed accidentally, and color can be difficult to distinguish for some readers. If the categories matter to analysis or reporting, add a separate Status column such as Review, Approved, or Hold and sort by that text instead.

For a nonalphabetical sequence, use a custom list. In the Sort dialog, choose the relevant column and select Custom List as the order, then choose or enter the sequence. A priority column might use High, Medium, Low rather than alphabetical order. Custom-list availability and management can vary by Excel version and platform, so a dedicated numeric rank column is a dependable alternative when a workbook must behave consistently across different systems.

Sort left to right instead of top to bottom

Most Excel sorts arrange records vertically: rows move up or down. If your categories run across columns instead, the Sort dialog can sort horizontally. Choose Data > Sort, select Options, and choose Sort left to right. Then specify the row containing the values that determine the order. This is appropriate for layouts where each column is a period or category, but it is less common for ordinary record lists.

Horizontal sorting moves columns, so check whether formulas, labels, and other related content are included in the selected range. As with a vertical sort, do not sort a small isolated part of a larger structure unless moving only that part is intentional. If the worksheet is intended for analysis, a conventional layout with one record per row is usually easier to sort, filter, and summarize.

Use the SORT function for a separate sorted view

Excel for Microsoft 365 also has the SORT function, which returns a sorted copy of a range in another area rather than rearranging the original cells. It is available in Microsoft 365 and Excel 2021 or later. For example, suppose A1:C5 contains headers in row 1 and four records in rows 2 through 5: names in column A, departments in B, and sales in C. With the records in A2:C5 and sales in the third column, enter =SORT(A2:C5,3,-1) in an empty cell. The result spills into adjacent cells, placing the highest sales first; the source range stays in its original order.

In that example, if the sales values are 120, 85, 150, and 100, the output order is 150, 120, 100, then 85, with each row’s name and department moving together in the returned view. The argument 3 identifies the third column of the selected range, and -1 requests descending order. Use 1 for ascending order. Leave enough empty cells below and to the right for the returned array; occupied cells in its spill area can cause a spill error.

Use the Sort dialog when you need to change the source list’s actual order, or when you need options such as sorting by color. Use SORT when you want a live, separate view that updates as source values change. The function does not replace the original data, and its result is not an editable reordered copy of the source records.

Common sorting problems and fixes

If numbers appear in an unexpected order—for example, 1, 10, 2—the values may be stored as text. Check for leading apostrophes, spaces, or inconsistent formats, and convert the affected values to numbers before sorting. Dates can have a similar problem: text that looks like a date may sort alphabetically instead of chronologically. Use a consistent date format and verify that Excel recognizes the values as dates.

If only one column moved, undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then repeat the sort and expand the selection. Also inspect whether blank rows split the data into separate blocks. If repeated values appear in an order you did not expect, remember that a single-column sort does not specify a meaningful order within ties; add a second sort level when that order matters.

To reduce risk, keep a source copy when the data is important, use a table for an expanding list, and verify a few complete records after sorting. Check both the first and last rows, and confirm that identifying fields still match their related dates and amounts. If a sort is part of a repeatable report, document the sort fields and their priority so another person can reproduce it.

Frequently Asked Questions

How do I sort an Excel column without mixing up rows?
Click a cell in the column and use the Data tab’s sort command. If Excel asks, choose Expand the selection. This moves the entire row with the sorted value. Avoid choosing to sort only the selected column when its values belong to records in neighboring columns.

How do I keep the header row at the top?
Open Data > Sort and select My data has headers if the first row contains labels. Check the result before continuing: the header should remain above the sorted records. Excel tables also identify their header row and provide sort controls in the header cells.

Can I sort by two columns in Excel?
Yes. Open Data > Sort, choose the primary field, select Add Level, and set the secondary field. Excel sorts by the second field only within groups that tie on the first field.

Why does Excel sort 1, 10, 2 instead of 1, 2, 10?
The values may be text rather than numbers. Convert them to numeric values consistently, then sort again. Hidden spaces or apostrophes can also affect how Excel interprets a cell.

Can I sort by color or priority?
Excel can sort by cell color, font color, or icon through the Sort dialog when those options apply. For a priority sequence such as High, Medium, Low, use a custom list or add a numeric ranking field to make the intended order explicit.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.