SORT Function in Google Sheets
Returns a sorted copy of a range, sorted by one or more columns ascending or descending. Doesn't modify the source — produces a new array.
Syntax
SORT(range, sort_column1, is_ascending1, [sort_column2, is_ascending2, ...])Returns: A sorted copy of range.
Excel equivalent: SORT (identical, requires Excel 2021+ or Microsoft 365)
Parameters
| Name | Required | Description |
|---|---|---|
| range | Required | The range to sort. |
| sort_column1 | Required | Column number (1-based) within range to sort by, OR an external range the same length as range. |
| is_ascending1 | Required | TRUE for ascending, FALSE for descending. |
| sort_column2, is_ascending2, ... | Optional | Additional sort levels for tiebreakers. |
Examples
Sort by revenue descending
=SORT(A2:D100, 4, FALSE)Sorts A2:D100 by column 4 (D) descending — highest first.
Multi-level sort: category ascending, then revenue descending
=SORT(A2:D100, 1, TRUE, 4, FALSE)Primary sort by column 1 ascending, ties broken by column 4 descending.
Sort with FILTER
=SORT(FILTER(A2:D100, B2:B100="West"), 4, FALSE)Filter first, then sort the result. FILTER+SORT is the idiomatic pattern for "top N matching rows".
When to use an alternative
- SORTN — You only want the top N rows from the sorted result.
- QUERY with ORDER BY — You're already using QUERY for filtering — adding ORDER BY is simpler than wrapping with SORT.
- RANK + INDEX/MATCH — You want positional rank rather than rearranging rows.
Common errors and how to fix them
Sort breaks row associations
Cause: Sorted column 4 only without including the other columns.
Fix: Pass the FULL range (A2:D100, not just D2:D100) so SORT moves whole rows together.
Header included in sort
Cause: Started range from row 1 instead of row 2.
Fix: Either exclude the header from range, or wrap with a manual header concatenation.
Related functions
Frequently Asked Questions
Does SORT modify the original data?
No. SORT returns a new array. The source range stays exactly as-is — this is different from the menu Data → Sort range action which mutates the data in place.
How do I sort by date when dates are stored as text?
Convert with DATEVALUE inside the sort: SORT(A2:C100, DATEVALUE(A2:A100), TRUE). If dates are already real date values, just sort by the column position. Text dates are almost always a data hygiene problem worth fixing at the source.