<< Go back to all functions

SORT

The SORT function in Google Sheets allows you to sort the rows of a given array or range by the values in one or more columns. Whether you need to sort sales data, student grades, or any other set of data, the SORT function simplifies the task. Read on to learn more about its syntax, parameters, and usage.

Function Syntax and Parameters

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

Parameters:

  • range: The range or array to sort.
  • sort_column: The column index or range whose values will be used for sorting.
  • is_ascending: A boolean value (TRUE or FALSE) that determines the sort order (ascending or descending). TRUE for ascending and FALSE for descending.
  • [sort_column2], [is_ascending2]: [Optional] Additional column index or range and sort order for secondary sorting.

Step-by-Step Tutorial

  1. Sorting a range by a single column:

    • Example: =SORT(A1:B5, 2, TRUE)
    • Result: Sorts the range A1:B5 in ascending order based on the values in column 2.
  2. Sorting a range by multiple columns:

    • Example: =SORT(A1:C5, 1, FALSE, 3, TRUE)
    • Result: Sorts the range A1:C5 in descending order based on the values in column 1, and then in ascending order based on the values in column 3.

Use Cases and Scenarios

  1. Data Analysis: Sort data by a specific column to identify trends or outliers.
  2. Leaderboard: Sort scores or rankings to create a leaderboard.
  3. Inventory Management: Sort products by name, quantity, or any other attribute.

Related Functions

  • FILTER: Selects a subset of data based on specified criteria.
  • QUERY: Extracts data from a range based on specified conditions.
  • ARRAYFORMULA: Allows the use of array functions in a range instead of applying them to each individual cell.

Related Articles