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
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
1forsort_column(it's the index withinrange, 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;
SORTitself never mutates the source range.
Related formulas
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.