Google Sheets SORT Formula: Syntax, Examples, and Fixes

How-to basics · Updated November 3, 2026

Google Sheets SORT Formula: Syntax, Examples, and Fixes

In Google Sheets, use =SORT(A2:C10,2,TRUE) to sort the rows in A2:C10 by the second column, from low to high. Change TRUE to FALSE for high to low; the formula creates a sorted result without rearranging the source data.

What the SORT formula does

SORT orders the rows in a range according to values in one or more columns. It is useful when you want a live sorted view of a table while leaving the original entries in place. If values in the source range change, the formula’s result updates to reflect the new order.

A key benefit is that SORT moves complete rows, not just the values in the column being sorted. For example, if a table has product names, prices, and stock counts, sorting by price keeps each product’s name and stock count beside its correct price. This is safer than sorting one column by itself, which can disconnect related records.

SORT is an array formula: it can return multiple rows and columns from one formula cell. The result expands into neighboring cells, so the output area must be clear. It is not the same as using a menu command to reorder the source table; the formula displays a sorted copy instead.

SORT syntax and arguments

The function syntax is SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...]). The first three arguments set the data to sort, the sort key, and the direction. Additional sort-column and direction pairs provide tie-breakers.

  • range: The cells to return in sorted order. Include all columns that belong together in each record.
  • sort_column: The column used as the sort key. When you give a number, it is the column’s position within the selected range, not its sheet letter.
  • is_ascending: Use TRUE for ascending order or FALSE for descending order. Text generally sorts A to Z or Z to A; numbers sort low to high or high to low.
  • Additional pairs: Optional sort keys used when earlier keys match. Each key needs its own direction.

For example, if the selected range begins in column B, its first column is sort key 1 and its second column is sort key 2—even if the second column on the sheet is C or D. Keeping this relative-position rule in mind prevents a common mistake when a table does not start in column A.

Basic examples for ascending and descending order

Suppose A2:C10 contains product names in column A, prices in B, and units in stock in C, with headers in row 1. To sort the full records by price from least to greatest, put this formula in an empty cell outside the source range:

With product names in A2:A10, prices in B2:B10, and stock counts in C2:C10, use:

=SORT(A2:C10,2,TRUE)

The result contains the same three columns, ordered by price ascending. The number 2 means “the second column of A2:C10,” which is column B. Because the formula starts at row 2, the header is not included in the sort and will not be treated as a product record.

To show the most expensive products first, keep the same cell layout and change the direction:

=SORT(A2:C10,2,FALSE)

For a single-column list, select just that column as the range. With names in A2:A10, this formula returns the names in alphabetical order:

=SORT(A2:A10,1,TRUE)

Here, 1 refers to the first—and only—column in the selected range. If you sort a full table, use the full table as the first argument rather than sorting only the key column.

Sort by more than one column

Multiple sort keys let you define what happens when several rows have the same value in the main key. For example, a staff list could be sorted by department A to Z and then by employee name A to Z. The second key matters only within groups that tie on the first key.

With employee names in A2:A20, departments in B2:B20, and start dates in C2:C20, sort the full records by department ascending, then by name ascending:

=SORT(A2:C20,2,TRUE,1,TRUE)

To sort those same records by department A to Z and, within each department, by start date from newest to oldest, use:

=SORT(A2:C20,2,TRUE,3,FALSE)

In both examples, the column numbers are positions inside A2:C20: department is 2 and start date is 3. You can add further key-direction pairs if the data calls for them. Choose keys in priority order; a later key cannot override an earlier one.

Sort only rows that meet a condition

SORT can be combined with FILTER when you need a sorted subset rather than every row. FILTER first selects records that meet a condition, and SORT then orders those returned records. The ranges used by FILTER must have compatible row counts.

With task names in A2:A100, owners in B2:B100, and status values in C2:C100, return only tasks marked Open and sort them by owner A to Z:

=SORT(FILTER(A2:C100,C2:C100="Open"),2,TRUE)

The number 2 now refers to the second column of the filtered result, which is still the owner column. If there are no matching rows, FILTER may return an error unless you supply its optional value-if-empty argument. Check the status spelling and any extra spaces if the result is unexpectedly empty.

Formula sorting versus the Data menu

Choose a formula when you want a separate view that updates as source values change, need sorted results for another calculation, or want the original order preserved. Choose a menu sort when you intend to rearrange the actual rows in the source table and do not need a formula-driven copy.

In Google Sheets in a web browser, select the relevant cells and use Data > Sort range > Advanced range sorting options to sort a selected range. If the selection includes a header, enable the option indicating that the data has a header row, then choose the sort column and direction. Sorting a range rather than a single key column helps keep related values together.

A formula is also convenient when you want the same sorted view to appear in a report or dashboard. However, its output is a result, not a second editable copy of the source table: edit the original records, not individual cells in the spilled result. Menu sorting changes row order in the selected sheet range, so consider whether the original order has meaning before applying it.

Excel also has a SORT function, but this page describes Google Sheets in a browser. Menu labels and some formula behavior can differ between spreadsheet products, so do not assume an Excel instruction applies verbatim in Sheets.

Headers, blank cells, and data quality

SORT does not automatically identify a header row in a formula range. If the range includes its header, the header is sorted along with the data and may end up among the records. Exclude the header by starting the formula at the first data row, or place a header separately above the formula result.

Make sure values that should sort together use consistent data types. A genuine date value may not sort as expected beside dates stored as text, and numbers entered as text can behave differently from numeric values. If the order looks wrong, inspect a few cells’ underlying values and formatting rather than assuming the displayed appearance tells the whole story.

Blank cells and incomplete records can also affect the result. Decide whether rows with missing keys should be included, and consider filtering them out if they do not belong in the view. For custom business sequences—such as High, Medium, Low—ordinary alphabetical sorting may not match the intended priority. A helper column with numeric ranks is one straightforward way to supply a sort order that matches your needs.

Common SORT problems and fixes

  • #REF! or an array expansion message: Clear cells in the area where the sorted rows need to appear. A value, merged cell, or other obstruction can prevent the result from expanding.
  • The wrong column controls the order: Recount the columns from the left edge of the range in the first argument. The sort-column number is relative to that range.
  • The header appears in the results: Start the range below the header. SORT has no header-row setting in its formula syntax.
  • Only one column moves: Use the complete record range as the first argument, not only the sort-key column.
  • The output does not change as expected: Check that the formula references the cells you edited and that those values are stored in the expected format.
  • The result is empty or reports no matches: If SORT is wrapped around FILTER, verify the filter condition, including spelling, spaces, and capitalization where relevant.

Also check for overlapping formulas. A SORT result that needs to expand into cells already occupied by another formula cannot overwrite them. Moving the output formula to a larger clear area often resolves the issue without changing the source data.

Frequently Asked Questions

Does SORT change the original data?
No. A SORT formula returns an ordered result elsewhere in the sheet. To change the source row order itself, use a Data menu sort on the intended range.

How do I sort a Google Sheets column alphabetically?
With the list in A2:A, enter =SORT(A2:A,1,TRUE) in a clear cell. Exclude any header from the range, or it will be included as a value to sort.

How do I sort from largest to smallest?
Set the direction argument to FALSE. For example, with a complete table in A2:C20 and the numbers to sort by in its second column, use =SORT(A2:C20,2,FALSE).

Can SORT use a column outside the returned range?
SORT’s sort key is specified as a column within the data range or as an appropriate sort-column reference. If the key is outside the records you want returned, consider including it in a working range or using a helper arrangement so the key and returned rows stay aligned.

Why can’t I type over a SORT result?
The formula produces an array output, so individual result cells are controlled by the formula in its top-left cell. Edit the source data or change that formula instead; make sure the output area is clear enough for the result to expand.

Can I sort in a custom order such as High, Medium, Low?
Yes, but alphabetical order will not express that priority by itself. Add a helper column assigning a rank to each category, then sort the full records by that rank. You can hide the helper column in the displayed report if needed.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.