Arraymedium

SORT()

Sorts the rows of a range by values in one or more columns.

Syntax
fx
=SORT(range, [sort_column], [is_ascending], [sort_column2], [is_ascending2], ...)
Arguments
ArgumentDescription
rangeThe range or array to sort.
[sort_column]The column index within range (or column reference) to sort by. 1-indexed.
[is_ascending]TRUE to sort ascending, FALSE for descending. Defaults to TRUE.
Example
fx
=SORT(A2:B100, 2, TRUE)

Paste this into Google Sheets to run it. The live playground on this site covers 24 of the 61 functions, and SORT isn't one of them yet.

Common pitfalls

  • Sorting a single column? Pass 1 for sort_column (it's the index within range, not an absolute column letter).
  • Multi-key sort: list (column, ascending) pairs in order. The first key dominates ties broken by subsequent keys.
  • Returns an array. To sort in place you'd need to copy-paste-values; SORT itself never mutates the source range.
Related formulas
SORTN()
Returns the first n items of a sorted range, for top-N or bottom-N selection.
FILTER()
Returns a filtered version of the source range, returning only rows or columns which meet the conditions.
QUERY()
Runs a Google Visualization API Query Language query across data.
Used by
FILTER()
Returns a filtered version of the source range, returning only rows or columns which meet the conditions.
UNIQUE()
Returns unique rows in the provided source range, discarding duplicates.
SORTN()
Returns the first n items of a sorted range, for top-N or bottom-N selection.
SEQUENCE()
Generates a sequence of numbers, returned as an array of the requested shape.