What SORT Does
The SORT function rearranges the rows in a given range or array based on the values in one or more columns. It returns a new sorted array without modifying the original data, making it a non-destructive way to organize information. You can sort in ascending or descending order and chain multiple sort criteria together.
Syntax
=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])
| Parameter | Description |
|---|---|
| range | The data range or array to sort. |
| sort_column | The index of the column within range to sort by (1 = first column). |
| is_ascending | TRUE for A-Z / smallest first; FALSE for Z-A / largest first. |
| sort_column2, is_ascending2 | Optional additional columns to break ties. |
If you pass only the range with no other arguments, SORT defaults to sorting by the first column in ascending order.
Basic Examples
Sort a list of names alphabetically
Suppose column A contains employee names:
| A | |
|---|---|
| 1 | Dana |
| 2 | Amir |
| 3 | Chen |
=SORT(A1:A3, 1, TRUE)
Result:
| Output |
|---|
| Amir |
| Chen |
| Dana |
Sort sales data by revenue (highest first)
| A | B | |
|---|---|---|
| 1 | Product | Revenue |
| 2 | Widget | 4500 |
| 3 | Gadget | 12000 |
| 4 | Bolt | 780 |
=SORT(A2:B4, 2, FALSE)
Result:
| Product | Revenue |
|---|---|
| Gadget | 12000 |
| Widget | 4500 |
| Bolt | 780 |
Sort by department, then by hire date
| A | B | C | |
|---|---|---|---|
| 1 | Name | Dept | Hire Date |
| 2 | Lee | Sales | 2022-03-15 |
| 3 | Priya | Eng | 2021-06-01 |
| 4 | Sam | Sales | 2020-11-20 |
=SORT(A2:C4, 2, TRUE, 3, TRUE)
This sorts first by department (column 2) alphabetically, then by hire date (column 3) from earliest to latest.
Advanced Examples
Sort filtered results dynamically
Combine SORT with FILTER to show only rows matching a condition, already in order:
=SORT(FILTER(A2:C100, B2:B100="Sales"), 3, FALSE)
This pulls all Sales department rows and sorts them by the third column (e.g., revenue) from highest to lowest. Because both functions produce arrays, the result updates automatically when the underlying data changes.
Sort with a calculated column
You can sort by a computed array rather than a column index. For example, to sort products by profit margin (Revenue minus Cost):
=SORT(A2:C20, C2:C20 - B2:B20, FALSE)
Here the sort_column argument is an array expression instead of a column number, and SORT arranges rows so the largest margin appears first.
Common Mistakes
- Using a column index that is out of range. If your data has three columns and you set
sort_columnto 5, you will get an error. The index is relative to the range you pass, not the entire sheet. - Forgetting to anchor the range when copying the formula. If you drag the formula down or across, relative references will shift and your sorted output may pull from the wrong cells. Use
$A$2:$C$100or place the SORT formula in a separate area of the sheet. - Mixing up TRUE and FALSE for sort direction. TRUE means ascending (A-Z, 1-9), FALSE means descending (Z-A, 9-1). It is a common slip to reverse them.
SheetAI Tip
Don't want to memorize this syntax? With SheetAI, just type what you need in plain English and the formula is generated for you. Install SheetAI to try it free.