Data Transformation FormulaGoogle Sheets V8 Engine Verified

Google Sheets SORT: Sort Data by Multiple Columns Ascending/Descending

SORT reorders the rows of an array or range based on values in one or more specified columns without modifying the original raw data table.

Formula Syntax:=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])
πŸ’‘ Best Practice: Always try complex formulas on a copy of your file first before applying them to active production data.

Technical Overview & Engine Mechanics

The SORT function sorts the rows of a specified array or range by the values in one or more columns. As a dynamic array function, SORT outputs the ordered dataset into fresh cells without altering the original order of source records. You can specify ascending or descending order per sort column and chain multiple tie-breaker sorting criteria (e.g., sort by Department ascending, then by Salary descending).

Formula Comparison: SORT vs. Alternatives

Unlike sorting a sheet via the Data menu (which rearranges raw cell positions and risks breaking formula references), the SORT formula is non-destructive and automatic. It pairs seamlessly with FILTER, UNIQUE, and QUERY.

Formula Parameters & Arguments

ArgumentTypeRequiredDescription
rangeRangeRequiredThe table to sort.
sort_columnInteger / RangeRequiredThe column index to sort by (1 = first col).
is_ascendingBooleanRequiredTRUE = Ascending (A-Z / Low to High), FALSE = Descending (Z-A / High to Low).

Real-World Spreadsheet Examples

Explore verified operational formulas used in enterprise reporting and database workflows:

Example 1: Sort Deals by Revenue Highest First

=SORT(A2:E100, 4, FALSE)
How it works: Sorts rows by Column 4 (Revenue) in descending order.

Example 2: Two-Tier Sorting (Department A-Z, then Salary High-to-Low)

=SORT(A2:D50, 2, TRUE, 4, FALSE)
How it works: Groups by Department, then sorts salaries within each group.

Example 3: Sort Filtered Results Dynamically

=SORT(FILTER(A2:D, D2:D > 5000), 4, FALSE)
How it works: Filters and sorts simultaneously.

Example 4: Multi-Tier Sorting: Department A-Z, Deal Size Descending

=SORT(A2:E500, 2, TRUE, 4, FALSE)
How it works: Sorts records primarily by Department (Column 2) ascending, and breaks ties by Deal Value (Column 4) descending.

Example 5: Top 10 Highest Spending Accounts

=CHOOSEROWS(SORT(A2:D1000, 3, FALSE), SEQUENCE(10))
How it works: Sorts entire dataset by spend descending and extracts the top 10 accounts.

Common Errors & Solutions

❌ #VALUE! Sort column out of range
Resolution: The sort_column index must be between 1 and the total number of columns in the range.
❌ #VALUE! Sort column index out of bounds
Resolution: The sort_column argument must be a valid relative column number within the range (e.g. 1 to 4 for range A2:D100), not an external sheet column letter.
❌ #REF! Overwrite error
Resolution: Clear destination cells to allow the sorted array to spill freely.

Performance Pro Tips

  • Pass FALSE as the 3rd argument for reverse chronological sorting on timestamps.

Frequently Asked Questions: SORT

What does TRUE vs FALSE mean in SORT?

TRUE sorts ascending (A-Z, 0-9). FALSE sorts descending (Z-A, 9-0).

Can SORT handle dates accurately?

Yes. Valid dates in Google Sheets are stored as serial numbers and sort chronologically.

How do I sort by a column that is not part of the output?

SORT accepts an external range for the sort column: =SORT(A2:B100, C2:C100, FALSE).

How does SORT handle empty rows?

Empty cells are placed at the very end of the sorted output, regardless of ascending or descending order.

Can SORT organize data horizontally across columns?

By default, SORT sorts rows. To sort columns horizontally, transpose data: =TRANSPOSE(SORT(TRANSPOSE(A1:Z4), 1, TRUE)).

Related Google Sheets Formulas