Spreadsheet Practice

SORT function in Google Sheets

Quick answer

SORT returns a range sorted by one or more columns and leaves the original data where it is.

Syntax
=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])
Most common use
=SORT(A2:C7,3,FALSE) returns Kim (Column 3 (Sales), largest first)

In Google Sheets you give the column number and TRUE for ascending or FALSE for descending, then add more column and order pairs as tie-breakers.

Works in
Google Sheets, with different arguments from Excel
Returns
An array: the rows of range in the new order.

Syntax

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

ArgumentRequired?What it is
rangeRequiredThe data to sort, usually without the header row.
sort_columnRequiredThe column to sort by: a number counted from the left edge of range, or a separate one-column range the same height.
is_ascendingRequiredTRUE for A to Z and smallest first, FALSE for Z to A and largest first.

Examples

Each result is calculated from the sample sheet by our formula engine in Sheets mode, the same one that grades the practice.

CellFormulaResultWhat it shows
E2=SORT(A2:C7,3,FALSE)Kimspills 6 × 3Column 3 (Sales), largest first
I2=SORT(A2:C7,2,TRUE,3,FALSE)Samspills 6 × 3Region A to Z, then the biggest sales first within each region
M2=SORT(A2:A7)Anaspills 6 × 1Just a range: sorts by its first column, A to Z

Try it live

This is the sample sheet. Change any value or edit a formula, and the results update.

Practice SORT

Graded instantly in Sheets mode, then re-checked on changed data.

Revenue leaderboard

In E2, sort the reps (columns A to C) by revenue, largest first.

Common mistakes

What you seeWhy, and how to fix it
Largest values end up lastis_ascending is TRUE or FALSE in Sheets. Use FALSE for largest first; a -1 copied from an Excel formula doesn't sort descending here.
The header row lands in the middle of the listStart range below the header: SORT(A2:C7,3,FALSE), not A1:C7. Keep the header in the row above the formula.
It sorts by the wrong columnsort_column counts from the first column of range, not from column A. In SORT(C2:E7,2,FALSE), 2 means column D.
#REF! with "Array result was not expanded"The cells the sorted rows need aren't empty. Clear them, including any old values pasted below the formula.

Tips

  • Sort filtered results in one step: =SORT(FILTER(A2:C7,B2:B7="East"),3,FALSE).
  • Sort by a column you don't show by passing a range as sort_column: =SORT(A2:A7,C2:C7,FALSE) lists names from best sales to worst.

SORT in Excel

Excel's SORT takes 1 for ascending and -1 for descending instead of TRUE and FALSE, and adds a by_col argument. To sort by several columns, Excel users usually reach for SORTBY.

The Excel SORT function, with practice →

Questions

How do I sort by two columns in Google Sheets?

Add another column and order pair: =SORT(A2:C7,2,TRUE,3,FALSE) sorts by region A to Z, then by sales from largest within each region.

Does SORT change my original data?

No. It writes a sorted copy where the formula is. To reorder the data itself, use Data > Sort range instead.

Updated Checked by running: every formula on this page was run by our formula engine on .