Excel SORT Function
SORT returns a dynamically sorted copy of a range or array.
Use it to keep reports, leaderboards, task lists, unique lists, and filtered result sets ordered without manually sorting the source data.
SORT syntax & arguments
Syntax
=SORT(array, [sort_index], [sort_order], [by_col])
-
1
array
RequiredThe range or array to sort.
-
2
sort_index
OptionalThe row or column number inside
arrayto sort by. If omitted, SORT uses the first row or column. -
3
sort_order
OptionalControls ascending or descending order:
1— Ascending: Sorts from smallest to largest or A to Z. This is the default.-1— Descending: Sorts from largest to smallest or Z to A.
-
4
by_col
OptionalControls the sort direction:
FALSE— Sort rows: Sorts rows by a column. This is the default.TRUE— Sort columns: Sorts columns by a row.
Example
=SORT(A2:D20, 3, -1)
Sort rows in A2:D20 by the third column in descending order.
SORT caveats
SORT returns a sorted copy, so the output updates with the source but does not physically rearrange the original data.
-
The source data does not move
SORT spills a separate sorted result while the original range remains in its existing order.
-
The sort index is positional
sort_indexis the row or column number insidearray, not the worksheet column letter. -
Sort direction changes by mode
By default SORT sorts rows by a column. Set
by_colto TRUE only when sorting columns by a row. -
The result spills into nearby cells
SORT returns a sorted copy with the same dimensions as
array. If that output would cover multiple cells and any target cell is blocked, Excel returns a#SPILL!error.
Sorting a dynamic list? SORT pairs naturally with FILTER and UNIQUE when the source result changes over time.
Intro SORT practice problem
Solve the intro problem directly here, or open it on its own page.
Advanced SORT practice problems
Use SORT alongside other Excel functions in realistic, less-prescriptive challenges.