Excel Function

Excel SORT function

Sort any range with a formula — results update automatically when your data changes.

SORT returns a sorted copy of a range as a spilled array. Unlike clicking the Sort button, the formula result updates live — add a row to your source data and the sorted output rearranges itself automatically.

Syntax

SORT(array, [sort_index], [sort_order], [by_col])
ArgumentWhat it means
array requiredThe range to sort.
sort_index optionalWhich column (or row) to sort by. 1 = first column (default).
sort_order optional1 = ascending (default), -1 = descending.
by_col optionalFALSE (default) = sort rows. TRUE = sort columns.

Basic examples

Sort A2:C50 by the first column, A to Z:

=SORT(A2:C50)

Sort the same range by the third column, highest to lowest:

=SORT(A2:C50, 3, -1)

Sorting by multiple columns

Sort by Region (column 1) ascending, then by Amount (column 3) descending:

=SORT(A2:C50, {{1,3}}, {{1,-1}})

Pass arrays of column numbers and sort orders, wrapped in curly braces, to sort by multiple columns at once.

Combining with other functions

Sort filtered results — first filter to "North" region, then sort by Amount descending:

=SORT(FILTER(A2:C100, B2:B100="North"), 3, -1)
💡 SORT vs SORTBY

SORT sorts by a column inside the array itself. SORTBY sorts one range based on a separate column — useful when you want to sort data but the sort key is in a different range.

Does SORT change my original data?
No. SORT outputs a copy of the data in sorted order. Your original range stays exactly as it was.
Can I sort text alphabetically and numbers numerically at the same time?
Yes — SORT handles mixed columns. Each column is sorted according to its own data type.
What is the difference between SORT and SORTBY?
SORT sorts by a column that is part of the array you are sorting. SORTBY sorts one range by a completely separate range — for example, sort a list of names by a corresponding score column that is not included in the output.

Practice SORT for real

Type it in a live spreadsheet, get instant feedback. No videos, no downloads.

Start practising free →