ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Dynamic arrays
  3. Sort by Multiple Columns in Excel (Formula and Menu)

Sort by Multiple Columns in Excel (Formula and Menu)

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To sort by multiple columns in Excel, go to Data > Sort, pick the first column in Sort by, then click Add Level and pick the second column in Then by. For a live result, use a formula instead: =SORTBY(A2:C9,A2:A9,1,C2:C9,-1) sorts by column A from A to Z, then by column C from largest to smallest.

Key takeaways

  • In the Sort dialog, the first level is the main sort; Then by levels only break ties.
  • SORTBY takes pairs of arguments: a column to sort by, then 1 for ascending or -1 for descending.
  • SORT can sort by several columns too, with array constants like {1,3} and {1,-1}.
  • The Sort button changes your data for good; SORT and SORTBY build a sorted copy that updates.
  • SORT and SORTBY need Excel 2021, Excel 2024 or Microsoft 365.
On this page+
  1. What does sorting by multiple columns mean?
  2. How to sort by multiple columns with the Sort dialog
  3. How to sort by multiple columns with SORTBY
  4. How to sort by multiple columns with SORT
  5. Sort button or formula: which should you use?
  6. Common mistakes when sorting by several columns
  7. Practise it

To sort by multiple columns in Excel, you have two choices. The Sort dialog (Data > Sort) lets you add levels, such as "Region A to Z, then Sales largest first", and reorders the data in place. A formula with SORTBY or SORT does the same sort in a new spot and keeps it up to date. This guide shows both on one small table, so you can pick the right one for a report or a job test.

What does sorting by multiple columns mean?#

Sorting by multiple columns means one column decides the main order, and the next column only decides the order of rows that tie. Think of a phone book: sorted by last name, then by first name for people who share a last name.

All the examples use this sales list in A1:C9:

ABC
1RegionRepSales
2NorthAna4200
3SouthBen3100
4NorthCara5600
5EastDev2900
6SouthEli4800
7EastFemi3700
8NorthGus3900
9SouthHana2500

The goal: group the rows by Region (A to Z), and inside each region put the biggest sales first. The result should be:

RegionRepSales
EastFemi3700
EastDev2900
NorthCara5600
NorthAna4200
NorthGus3900
SouthEli4800
SouthBen3100
SouthHana2500

How to sort by multiple columns with the Sort dialog#

The Sort dialog works in every version of Excel, on Windows and Mac. Use it when you want to reorder the data itself.

  1. Click one cell inside the data. Don't select a single column, or Excel may sort only that column.
  2. Go to Data > Sort. On Windows, the ribbon keys are Alt, A, S, S.
  3. Make sure My data has headers is ticked, so row 1 stays on top.
  4. In Sort by, choose Region. Keep Sort On as Cell Values and Order as A to Z.
  5. Click Add Level. In Then by, choose Sales and set Order to Largest to Smallest.
  6. Click OK.

The rows now match the result table above. You can add up to 64 levels. Use Delete Level to remove one, Copy Level to duplicate it, and the up and down arrows to change which level runs first. The top level always wins.

If your data has a filter on it, the same dialog opens from the filter arrow menus too. Our beginner's guide to sorting data covers single-column sorts and the warning boxes Excel shows.

How to sort by multiple columns with SORTBY#

SORTBY sorts a range by one or more other ranges, and you list them in order of importance. The syntax is:

Excel formula
=SORTBY(array, by_array1, sort_order1, by_array2, sort_order2, ...)
PartWhat it meansExample
arrayThe cells you want back, sortedA2:C9
by_array1The main column to sort byA2:A9
sort_order11 = ascending (A to Z, smallest first), -1 = descending1
by_array2The tie-breaker columnC2:C9
sort_order2Order for the tie-breaker-1

Type this in E2 and press Enter:

Excel formula
=SORTBY(A2:C9,A2:A9,1,C2:C9,-1)

The formula spills: it fills E2:G9 with the sorted table, starting with East, Femi, 3700. If you change Gus's sales to 6000, he jumps to the top of North right away. The cells to the right and below E2 must be empty, or you get a #SPILL! error.

SORTBY is handy because the sort columns don't have to be part of the result. =SORTBY(B2:B9,A2:A9,1,C2:C9,-1) returns only the rep names, in the same order.

How to sort by multiple columns with SORT#

SORT can also use more than one column. Put the column numbers in curly brackets as the second argument, and the orders in curly brackets as the third:

Excel formula
=SORT(A2:C9,{1,3},{1,-1})

{1,3} means "sort by column 1 of the range, then column 3". {1,-1} means "column 1 ascending, column 3 descending". The result is the same as the SORTBY formula above.

SORT is shorter when the sort columns are inside the range you return. SORTBY is clearer to read and doesn't break if you insert a column, because it points at real ranges instead of column numbers. See SORT vs SORTBY for a full comparison, and the SORT function guide for every argument.

Sort button or formula: which should you use?#

Use the Sort button when you want to tidy the data once. Use a formula when the data changes and the sorted view must stay correct.

NeedBest tool
Clean up a list before sending itSort dialog
Works in Excel 2019 or olderSort dialog
A report that re-sorts when numbers changeSORTBY or SORT
Keep the original order untouchedSORTBY or SORT
Sort by a custom order like High, Medium, LowSort dialog with a custom list, or SORTBY with MATCH

SORT and SORTBY need Excel 2021, Excel 2024 or Microsoft 365. In older versions they show #NAME?. The article on the Sort button vs the SORT function goes deeper into this choice. For orders that aren't alphabetical, read how to do a custom sort.

Common mistakes when sorting by several columns#

Most multi-column sorting problems come from the level order or the selection. Check these:

  • Levels in the wrong order. If Sales is the top level, the whole list sorts by sales and the regions get mixed. Move Region to the top with the arrow buttons.
  • Only one column moved. If you selected column C and chose Continue with the current selection, the sales values moved but the names didn't. Press Ctrl+Z (Mac: ⌘Z) at once to undo.
  • Headers sorted into the data. Tick My data has headers, or the word "Region" ends up between the rows.
  • Numbers stored as text. "900" stored as text sorts as text, so it can land after "4200". Convert the column to numbers first.
  • Wrong sign in SORTBY. Use 1 or -1. A 0 or a 2 returns a #VALUE! error.
  • Blank rows. A blank row splits the data, and the Sort dialog may only see the part above it. Remove blank rows or select the whole range first.

If you need to filter and sort together, wrap a FILTER inside SORTBY, or turn on filter buttons with Ctrl+Shift+L (Mac: ⌘⇧F) and sort from the arrows.

Practise it#

Multi-level sorts are a common task in Excel job tests, and they're easy to get backwards. Practise the SORT function in a live spreadsheet: you type the formula and it checks it instantly. Then practise filtering and sorting a table with the filter buttons. Start with the exercise on this page: one SORTBY formula, two sort levels.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

In E2, use SORTBY to sort the whole table A2:C9 by Region from A to Z, then by Sales from largest to smallest.

fx
ABCDEF
1
Region
Rep
Sales
Sorted list
2
North
Ana
4200
3
South
Ben
3100
4
North
Cara
5600
5
East
Dev
2900
6
South
Eli
4800
7
East
Femi
3700
8
North
Gus
3900
9
South
Hana
2500
10
11
12

Tip: Start with the whole table, then add two pairs: the Region column with 1, and the Sales column with -1.

Practise this in a lesson

LessonSORT: order data with a formulaSort a table by any column, ascending or descending, and combine SORT with FILTER and UNIQUE.LessonFilter a tableTurn on filter buttons with Ctrl+Shift+L, filter by one or several values and by a number condition, total and count only the visible rows with SUBTOTAL, then clear the filters.Function guideSORTSort a range with a formula using Excel's SORT. Sort by any column, highest first, or combined with FILTER. Includes a live exercise.

Frequently asked questions

How do I sort by two columns in Excel?

+

Click inside the data and go to Data > Sort. Choose the first column in Sort by, click Add Level, choose the second column in Then by, set the order for each and click OK.

How do I sort by multiple columns with a formula?

+

Use SORTBY with one pair of arguments per column, for example =SORTBY(A2:C9,A2:A9,1,C2:C9,-1). The first pair is the main sort and the second pair breaks ties.

Can the SORT function sort by more than one column?

+

Yes. Put the column numbers and orders in curly brackets: =SORT(A2:C9,{1,3},{1,-1}) sorts by column 1 ascending, then column 3 descending.

Why does Excel only sort one column and not the whole row?

+

You probably selected a single column before sorting and chose Continue with the current selection. Select one cell inside the data instead, or choose Expand the selection, so every row moves together.

What order does Excel use for multiple sort levels?

+

Excel sorts by the top level first. Each lower level only reorders rows that have the same value in every level above it.

Sources

  • SORTBY function - Microsoft Support
  • Sort data in a range or table - Microsoft Support
  • SORT function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does sorting by multiple columns mean?
  2. How to sort by multiple columns with the Sort dialog
  3. How to sort by multiple columns with SORTBY
  4. How to sort by multiple columns with SORT
  5. Sort button or formula: which should you use?
  6. Common mistakes when sorting by several columns
  7. Practise it

Keep reading

Data tools· 6 min read

How to Sort Data in Excel by One or More Columns

To sort data in Excel by one column, click any cell in that column and choose Data > Sort A to Z or Sort Z to A. To sort by several columns, choose Data > Sort, pick the first column, then click Add Level for the next one. Click a single cell first so Excel keeps each row together.

Comparisons· 7 min read

Sort Button vs SORT Function in Excel

The Sort button on the Data tab rearranges the rows of your table in place, once, and works in every version of Excel. The SORT function leaves the original data alone and returns a sorted copy that updates when the data changes, but it needs Excel 2021, Excel 2024, Microsoft 365 or Excel for the web.

Data tools· 5 min read

Custom Sort in Excel: Sort by Your Own Order

To do a custom sort in Excel, go to Data > Sort, choose the column in Sort by, and set Order to Custom List. Type your order, such as High, Medium, Low, click Add and then OK. Excel sorts the rows in that order instead of alphabetically. With a formula, use =SORTBY(A2:C9,MATCH(B2:B9,E2:E4,0)), where E2:E4 holds the order.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free