Excel Sort Examples: Rows, Text, Dates, and Custom Lists

Formulas & functions · Updated November 3, 2026

Excel Sort Examples: Rows, Text, Dates, and Custom Lists

To sort a worksheet in Excel for Microsoft 365 on Windows, select a cell in the data, then choose Data > Sort A to Z or Data > Sort Z to A; for a specific column or several rules, choose Data > Sort. Excel sorts whole rows when it recognizes a related data range, so each value stays with the correct record.

How Excel sorting works

Sorting changes the order in which records appear; it does not remove records or change the values being sorted. A list of orders might be arranged by date, customer, or amount, while the other fields in each order move along with it. This is why sorting only one column of a multi-column list can cause serious errors: names, dates, and amounts may no longer refer to the same record.

Excel uses the selected column as a key and applies the chosen order to the corresponding rows. For a simple ascending sort, text is generally arranged alphabetically, numbers from smallest to largest, and dates from oldest to newest. Descending reverses the order for the selected sort key. Excel recognizes data types when it can, but numbers stored as text or dates stored as text may not sort as expected.

Sorting is different from filtering. A sort rearranges the displayed records; a filter temporarily hides records that do not meet conditions. You can use both: filter a table to show a subset, then sort the visible results. If you want a separate, formula-driven sorted copy that updates as source data changes, a dynamic array function may be more suitable.

Example 1: Sort an entire list by one column

Suppose a table has columns for Product, Region, and Sales. To put the largest sales amount first, click a cell in the table and choose Data > Sort Z to A if the selected cell is in the Sales column. In Excel, this command sorts text Z to A and numeric values largest to smallest. For a clearer, explicit setup, choose Data > Sort, set Sort by to Sales, set Sort On to Cell Values, and choose Largest to Smallest under Order.

For example, if the rows are Widget/East/120, Gadget/West/85, Cable/East/150, Adapter/North/95, and Mouse/West/110, sorting Sales from largest to smallest gives Cable (150), Widget (120), Mouse (110), Adapter (95), and Gadget (85). The product and region values remain attached to their sales figures because Excel moves the rows together.

If Excel asks whether to expand the selection, choose Expand the selection when the neighboring columns belong to the same records. Choosing to sort only the selected cells can mismatch the data. Before sorting, check that the range has a single header row and no completely empty row or column splitting the records into separate blocks.

Example 2: Sort text alphabetically

To alphabetize a list of names, select a cell in the name column and choose Data > Sort A to Z. For a reversed list, use Data > Sort Z to A. If the names are part of a wider table, sort using a name cell or select the full table first, and confirm that Excel includes every column. The Sort dialog lets you identify the exact field instead of relying on which cell was active.

Text sorting is useful for customer lists, product catalogs, and lookup tables, but it follows the stored text rather than a person’s interpretation of it. Leading spaces can make an entry sort unexpectedly; inconsistent spelling and punctuation can also split values that look similar. If a list contains codes such as A2 and A10, alphabetical ordering may put A10 before A2 because it compares text characters, not the numeric meaning of the suffix. A helper column or a consistent code format can make the intended order clearer.

Example 3: Sort dates and times

For a date column containing real Excel dates, choose Data > Sort Oldest to Newest to put earlier dates first, or Data > Sort Newest to Oldest to put recent dates first. In the Sort dialog, select the date field and choose the corresponding order. Excel dates are stored as numbers, so changing how a date looks with cell formatting does not usually change its chronological position.

For instance, a service log can be sorted newest to oldest to bring recent visits to the top. If dates appear in a surprising order, check whether some entries are text rather than real date values. A telltale sign is that dates that look similar behave differently when formatted or sorted. Converting the text consistently to real dates before sorting is safer than trying to correct the order by hand. Times work similarly: sorting actual time values places them in time order, while text such as “9:00 AM” may not.

Example 4: Use multiple sort levels

Use multiple levels when one field is not enough to produce the order you need. For example, to group a sales list by Region and then put each region’s highest sale first:

  1. Click in the data and choose Data > Sort.
  2. Choose Region under Sort by, keep Cell Values, and select A to Z.
  3. Select Add Level. For the next level, choose Sales and select Largest to Smallest.
  4. Check that My data has headers is selected if the first row contains column names, then select OK.

The first level groups the regions alphabetically. The second level sorts sales within each region; it does not rearrange the regions themselves. You can add further levels when the records still need ordering within ties, such as sorting equal sales amounts by customer name. The order of levels matters: Excel applies the first level first, then uses later levels to order records tied at earlier levels.

Example 5: Sort by a custom order or cell color

Alphabetical order is not always the order a workflow needs. A project status list may need to appear as Not Started, In Progress, Waiting, Complete, rather than alphabetically. In the Sort dialog, choose the status column and open the Order list. Select Custom List, then choose a suitable list or create one by entering the items in the desired order. Custom lists are also useful for weekday or month names when the required sequence is not alphabetical.

Excel can also sort by cell color, font color, or a conditional-formatting icon. In Data > Sort, set Sort On to the relevant option, select the color or icon, and specify whether it should appear on top or at the bottom. A color sort does not interpret what a color means; it only places the selected visual category where you request. For reliable analysis, keep an explicit status or category value in the data instead of relying on color alone.

Example 6: Return a sorted copy with a formula

The SORT function returns a sorted array in a new location and leaves the original data in place. It is available in Microsoft 365 and Excel 2021 or later. With headers in A1:C1 and Product, Region, and Sales records in A2:C6, enter this formula in an empty cell outside the source range to sort all three columns by Sales from smallest to largest:

=SORT(A2:C6,3,1)

Here, 3 means the third column of the selected array, and 1 means ascending order. For the example records above, the returned rows are Gadget (85), Adapter (95), Mouse (110), Widget (120), and Cable (150), with each region kept beside its product and sales value. The formula does not include the header row, so add or display headers separately if needed. Leave enough empty space for the result to spill; cells blocking the output can cause a #SPILL! error.

To sort by more than one key in a formula, SORTBY can use separate sort ranges. With the same records in A2:C6, enter this formula in a clear area to sort Region A to Z and Sales largest to smallest within each region:

=SORTBY(A2:C6,B2:B6,1,C2:C6,-1)

The result groups East, North, and West in that order; within East, Cable (150) comes before Widget (120), and within West, Mouse (110) comes before Gadget (85). SORTBY is available in Microsoft 365 and Excel 2021 or later. Like SORT, it returns a separate result rather than physically rearranging the source rows.

Choosing the right sorting method

Use a direct ribbon sort for a quick, one-time rearrangement. Use the Sort dialog for multiple levels, a specific field, custom lists, or color-based ordering. Use SORT or SORTBY when you want a second view that can update with changes to a source range. These methods serve different purposes: formulas do not rearrange the original records, while a normal sort does.

  • Quick sort: Best for a single key, such as putting amounts from largest to smallest.
  • Sort dialog: Best when you need precise control or several levels.
  • Custom order: Best for sequences such as workflow stages that are not alphabetical.
  • Dynamic array formula: Best for a separate, automatically recalculated sorted view.

For regularly maintained lists, formatting the range as an Excel table can make sorting and filtering easier. Select a cell in the data and use Home > Format as Table, then confirm whether the table has headers. Table header drop-downs provide sort and filter commands, and new rows can be included as the table expands. On Mac, the Sort and table features are also available from the ribbon, though the dialog layout and some labels can vary slightly by Excel release. Excel for the web also supports common sorts, but desktop dialog options may differ.

Common sorting problems and how to avoid them

The most important safeguard is keeping records intact. Sort from a cell in a contiguous data range and pay attention to Excel’s selection prompt. If a worksheet includes separate sections, notes, or subtotals near the list, identify the exact range first rather than assuming Excel will infer the intended boundary. A backup or undo is useful if a sort produces an unexpected arrangement, but prevention is better when the workbook has formulas or complex layouts.

  • Only one column moved: Undo immediately, then sort the full record range or choose Expand the selection.
  • Headers were sorted as data: Open the Sort dialog and check My data has headers.
  • Numbers appear out of order: Check for numbers stored as text, extra spaces, or mixed formats in the column.
  • Dates are not chronological: Check whether every entry is a real date value rather than text that merely looks like a date.
  • Formula output will not appear: Clear the cells in the spill area and confirm that the output range is not blocked.

Sorting can also affect the way people interpret formulas that depend on relative positions, even when Excel adjusts cell references as rows move. Review formulas, subtotals, and any manually entered row numbers after a complex sort. A sort is not a permanent classification: if new records are added later, they may need to be sorted again unless you use a dynamic formula view or apply another sort.

Frequently Asked Questions

How do I sort a column without mixing up the other data?
Click a cell in the column and use the sort command. If Excel asks, choose Expand the selection so associated values in the same rows move together. Never sort just one field when the other columns describe the same records.

Can Excel sort by two columns?
Yes. Choose Data > Sort, set the first field, select Add Level, and set the next field. Excel applies later levels to records tied on the earlier levels.

How do I sort months in calendar order?
Use the Sort dialog’s Order > Custom List option and choose or create a January-through-December list. If the cells contain real dates rather than month names stored as text, sorting by date values may be more appropriate.

Can I sort a list automatically when it changes?
Use SORT or SORTBY in Microsoft 365 or Excel 2021 and later to create a separate sorted result that recalculates when source values change. A regular ribbon sort changes the current row order and does not automatically place later additions in their new position.

Why does Excel put my numbers or dates in the wrong order?
Some entries may be stored as text, have extra spaces, or use inconsistent formats. Check the underlying values and convert the column to a consistent data type before sorting; changing only the display format may not correct text entries.

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.