
When sorting orders by amount, move the complete rows so each amount stays with its customer. A worksheet sort changes their order in place. A formula can build a second, sorted view. Sorting is useful when you want to:
- see the largest and smallest values of numeric ranges;
- arrange text alphabetically to find the rows you need faster;
- order events by date and time to understand their sequence and what happened first.
For a one-time sort by several fields, set the order of the keys in the Sort dialog.
Sort data with built-in Excel tools
I know and use three ways to sort regular tables on a sheet (not pivot tables): the Filter, the context menu and the Sort dialog on the Data tab. Personally, I like the Filter best.
Sorting with the Filter
To sort with the filter, turn it on for the header row (Data → Filter or Ctrl+Shift+L) and use the drop-down menu of the column you need. It covers most of the basic options:
- ascending and descending;
- by fill color and font color;
- by cell icon.
The context menu
Right-click a selected range → Sort to sort it right in place, without any headers.
An interesting detail: the sort depends on which cell of the selection is active, that is, the side from which you started selecting. Excel sorts by the column of the active cell. Knowing this, you can quickly sort a multi-column range by its rightmost or leftmost column.
The Sort dialog on the Data tab
This is the most universal and flexible sorting tool in Excel. It lets you set exact parameters, use several levels and control the direction. Select the data range or any cell inside the table and go to Data → Sort. In the dialog:
- Column sets the field to sort by;
- Sort On sets the type of value: cell values, cell color, font color or conditional formatting icon;
- Order sets the direction: A to Z or Z to A for text, smallest to largest or largest to smallest for numbers, oldest to newest or newest to oldest for dates.
One of its most useful features is multi-level sorting, by several columns at once. For example, first by region, then within each region by manager, and within each manager by sales from largest to smallest. Add the second and third levels with Add Level: Excel applies them from top to bottom.
You can also sort by color and set the order of colors: first the rows with red fill (critical values), then yellow (warnings), then everything else. The same works with conditional formatting icons, like status indicators or arrows.
A setting many users don’t know about is the direction. By default, Excel sorts rows top to bottom, but in Options you can choose Sort left to right and reorder columns instead. That’s handy for time series, when you need to reorder months or quarters.
Important: if the table has a header row, make sure My data has headers is checked. Otherwise Excel may sort the headers together with the data.
Sort a table copy with formulas in Excel 2013
For A2:C6, sort the rows by numeric column C in descending order. H2:H6 calculates the ranks; J2:L6 returns the sorted copy. The source stays unchanged. C must contain numbers with no blank or error cells; tied amounts keep their source order. Enter all formulas with Enter.
H2, fill down to H6:
=SUMPRODUCT(--($C$2:$C$6>C2))+COUNTIF($C$2:C2,C2)J2, copy over J2:L6:
=INDEX($A$2:$C$6,MATCH(ROWS($J$2:J2),$H$2:$H$6,0),COLUMNS($J$2:J2))To sort A2:A6 by text length, first enter this in G2 and fill down to G6:
=LEN(A2)In H2, rank the lengths in ascending order and fill down to H6. Then use the INDEX formula above:
=SUMPRODUCT(--($G$2:$G$6<G2))+COUNTIF($G$2:G2,G2)Sorting with formulas in Excel 365
Excel 2021, Excel 2024 and Microsoft 365 include SORT and SORTBY. They return a sorted copy that updates with the source. Here the second column sets the descending order:
=SORT(A2:C100,2,-1)
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Name | Region | Sales | Name | Region | Sales | |
| 2 | Anna | North | 540 | Bob=SORT(A2:C6,3,-1) | South | 820 | |
| 3 | Bob | South | 820 | Dan | East | 820 | |
| 4 | Cleo | North | 310 | Anna | North | 540 | |
| 5 | Dan | East | 820 | Cleo | North | 310 | |
| 6 | Eve | South | 150 | Eve | South | 150 |
3 is the column to sort by (Sales), −1 means descending. Bob and Dan have equal sales and keep their original order. Change any number on the left and the copy re-sorts itself.
SORTBY can sort by a calculated value that isn’t in the table at all. For example, by the number of characters in the cell, shortest first:
=SORTBY(A2:A100,LEN(A2:A100),1)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Word | Length | Shortest first | |
| 2 | banana | 6=LEN(A2) | fig=SORTBY(A2:A6,LEN(A2:A6),1) | |
| 3 | fig | 3=LEN(A3) | kiwi | |
| 4 | kiwi | 4=LEN(A4) | apple | |
| 5 | apple | 5=LEN(A5) | banana | |
| 6 | plum tree | 9=LEN(A6) | plum tree |
SORTBY sorts A2:A6 by an array that isn’t in the table — the lengths. Words of equal length would keep their source order. Column B only shows the lengths; the formula doesn’t need it.
In Excel 2013, use LEN in a helper column, fill down and sort the table by that column.
=LEN(A2)Special sorting modes in !SEMTools
In my practice I often needed to sort data in the ways below, so I added procedures for them to make life easier. A couple of clicks is always more convenient than creating helper columns and writing formulas:
- sort a range by word endings, that is, by the last letters in alphabetical order (useful for grouping words with the same suffix);
- sort by the number of characters;
- sort by the number of words.
The add-in also has simple sorting of a selected range: A to Z for text, smallest to largest for numbers and dates, and in reverse.
All of them are in CHANGE → Range → Sort: Simple sort, By ending, By length, By number of words and Flip upside down.
Sort ranges by word endings, length or number of words in a couple of clicks, without helper columns.
!SEMTools solves this and hundreds of other tasks right in Excel!
Summary: which sorting method to choose
I hope you found what you were looking for on this page. The Filter is the fastest for everyday sorting, the Sort dialog for multi-level and color sorting, SORT and SORTBY in Excel 365 for a live sorted copy, and !SEMTools for sorting by length, word count or endings without helper columns.