Array

Google Sheets SORT Function — Syntax, Examples & Tips

Learn how to use the SORT function in Google Sheets to reorder rows by one or more columns. Includes syntax breakdown, practical examples, and common mistakes.

Syntax
=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])

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, ...])
ParameterDescription
rangeThe data range or array to sort.
sort_columnThe index of the column within range to sort by (1 = first column).
is_ascendingTRUE for A-Z / smallest first; FALSE for Z-A / largest first.
sort_column2, is_ascending2Optional 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
1Dana
2Amir
3Chen
=SORT(A1:A3, 1, TRUE)

Result:

Output
Amir
Chen
Dana

Sort sales data by revenue (highest first)

AB
1ProductRevenue
2Widget4500
3Gadget12000
4Bolt780
=SORT(A2:B4, 2, FALSE)

Result:

ProductRevenue
Gadget12000
Widget4500
Bolt780

Sort by department, then by hire date

ABC
1NameDeptHire Date
2LeeSales2022-03-15
3PriyaEng2021-06-01
4SamSales2020-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_column to 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$100 or 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.

Skip the formula. Describe what you need.

SheetAI lets you type what you want in plain English and generates the perfect formula — no syntax to memorize.

Try SheetAI Free