Back to functions
Lookup & Reference2026-03-180 related articles

SORT Function in Excel

Sort the contents of a range or array by one of its rows or columns.

Syntax

SORT(array, [sort_index], [sort_order], [by_col])

Arguments

array

Required

The range or array to sort.

sort_index

Optional

The row or column number within the array to sort by.

sort_order

Optional

Use 1 for ascending order or -1 for descending order.

by_col

Optional

Use TRUE to sort by columns instead of rows.

What it returns

Returns a sorted dynamic array.

What SORT does

SORT rearranges a range or array into ascending or descending order without changing the source data. It is especially useful in dynamic reports where the sorted output should update automatically as the data changes.

Practical examples

Sort a table by the third column

=SORT(A2:C10,3,1)

This sorts the rows in A2:C10 by the values in the third column in ascending order.

Sort a list in descending order

=SORT(A2:A20,1,-1)

This returns the values from A2:A20 from highest to lowest or from Z to A, depending on the data type.

Common mistakes and notes

sort_index is relative to the selected array

If you sort A2:C10, then 3 means the third column within that selection, not column C on the whole worksheet.

SORT also spills results

Like other dynamic array functions, SORT needs empty cells for the full result. Otherwise Excel may return #SPILL!.

Use SORTBY when the sort key is outside the array

SORT works best when the sort column is inside the selected array. If the sort key lives elsewhere, SORTBY is usually the better choice.

Related functions

Official documentation