Excel SORT Function (Dynamic Order) – Examples & Practice
Practice the Excel SORT function online with an interactive grid, instant feedback, and clear formula help.
Instruction
Sort rows in A2:C6 by the 2nd column in descending order.
Formula Syntax
=SORT(array, [sort_index], [sort_order], [by_col])
- array: Data to sort.
- [sort_index]: Column index within array (optional; defaults to 1).
- [sort_order]: 1 ascending, -1 descending (implementation details vary—verify in Help).
- [by_col]: Optional; sort columns instead of rows when TRUE.
What it does
SORT returns a sorted copy of an array or range, spilling the result in dynamic Excel. Use it whenever you need a formula-driven order that updates with data.
Excel SORT Function Examples
Sort by second column descending
=SORT(A2:C6, 2, -1)
Orders rows using column B inside the range (second column of A2:C6).
Default ascending on first column
=SORT(A2:C6)
Sorts by the first column ascending when sort arguments are omitted.
Sort filtered rows
=SORT(FILTER(A2:C6, C2:C6="North"), 3, 1)
Filters first, then sorts the result by the third column ascending.
dynamic-array-data.xlsx
| A | B | C | |
|---|---|---|---|
| 1 | Category | Amount | Region |
| 2 | A | 120 | North |
| 3 | B | 340 | South |
| 4 | A | 560 | North |
| 5 | C | 225 | West |
| 6 | B | 90 | South |
| 7 | Output |
Input Formula
Need Help?
Tips
- Pair with **FILTER** for “top exceptions sorted.”
- Leave blank space for the spill grid.
- Prefer **SORTBY** when you want to sort by a column not inside the returned columns.
SORT Function Use Cases
- Live leaderboards beside raw tables
- Consistent ordering before UNIQUE or lookups
- Dashboard tables without manual resort
- Teaching spill-based reporting
- Cleaner pipelines than helper sort columns
Common mistakes - SORT function not working
- Wrong
sort_indexafter columns move - Expecting locale-aware text rules without testing
- Mixing merged cells inside the spill area
- Sorting whole columns on massive sheets
- Forgetting FILTER when only a subset should be sorted
FAQ
Does SORT change the source data?
No. It returns a spilled sorted copy; original cells stay unchanged.
What is sort_index?
The column position inside the array to sort by (1 = first column of the array).
What values does sort_order use?
Typically 1 ascending (default) and -1 descending in modern Excel.
Can I sort by multiple columns?
Yes, using additional sort_index/sort_order pairs in supported versions.
Why #SPILL!?
The spill destination is blocked—clear cells or remove merges below the formula.
Comparison
| Tool | Live formula? |
|---|---|
| SORT | Yes |
| Sort dialog | One-time |
| SORTBY | Adds explicit “by array” control |
Example
=SORT(A2:C6, 2, -1)
Advanced examples
SORTBY for helper-free ordering
=SORTBY(A2:C6, B2:B6, -1) sorts the table by column B without choosing a sort_index number.
Tie-break columns
Stack multiple keys in SORTBY (when available) to break ties on name after sorting on score.