SORT Function in Google Sheets

Sort a range of data based on one or more columns using the SORT function.

SORT Function

The SORT function in Google Sheets sorts the rows of a range based on the values in one or more columns.

Syntax

SORT(range, sort_column, is_ascending, [sort_column2], [is_ascending2])
  • range: The range of cells to sort. This is a required parameter.
  • sort_column: The index or reference to the column to sort by. This is a required parameter.
  • is_ascending: TRUE to sort in ascending order, FALSE for descending order. This is a required parameter.
  • sort_column2: (Optional) Additional columns to sort by.
  • is_ascending2: (Optional) Order for the second sort column.

Examples

  1. Basic Sorting

Sort the range A1:B10 by the values in column A in ascending order:

=SORT(A1:B10, 1, TRUE)

This will return the sorted range.

  1. Multi-Level Sorting

Sort the range A1:C10 by column A in ascending order and then by column B in descending order:

=SORT(A1:C10, 1, TRUE, 2, FALSE)

This will return the range sorted by the specified criteria.

Notes

  • The function does not modify the original range; it returns a new sorted array.
  • You can use multiple levels of sorting by adding additional columns and orders.
  • FILTER: Filter a range based on specified conditions.
  • SORTN: Return a specified number of sorted rows.