SORT

Formulas / SORT
Organize a range or array.
SORT(array,[sort_index],[sort_order],[by_column])
  • array - range or array to sort
  • sort_index - [OPTIONAL] number that indicates the row or column to be sorted
  • sort_order - [OPTIONAL] number indicating the sort order
  • by_col - [OPTIONAL] logical value indicating the sort direction

Examples

  • =SORT(range)

    The SORT function can be used to sort data in a Sourcetable worksheet. This example will sort the data by the first column in the range in ascending order.

  • =SORT(range,1,1)

    The SORT function can also be used to sort by a specific column and order, where the 1 after the range is the column number that will be used to sort the data, and the 1 after that is the order. This example will sort the data by the first column in ascending order.

  • =SORT(range,1,-1)

    The SORT function can also be used to sort by a specific column and order.This example will sort the data by the first column in descending order.

Summary

The SORT function is a useful tool to easily organize data by sorting an array or range according to a specified criterion. It returns an array of the sorted elements. The SORTBY function is a better choice when sorting data in the grid.

  • The SORT function can sort data in one or more columns, returning a #VALUE! error if the sort_index, sort_order, or by_col is out of range.
  • The SORT function sorts a dynamic array of results.


Frequently Asked Questions

What is the SORT function?
The SORT function is used to sort a range or array of elements. It returns an array of the sorted elements.
What does SORTBY do?
The SORTBY function allows you to sort data in a table by referencing a specific column. It also respects column additions and deletions.
What are some examples of when you might use the SORT function?
The SORT function can be used for a variety of purposes, such as sorting a list of names alphabetically, sorting a list of numbers from smallest to largest, or sorting data in a table by a specific column.
How do I reference a column in a table using SORTBY?
To reference a column in a table using SORTBY, simply include the column name in the parameters of the SORTBY function. For example, if you wanted to sort a table by the "Last Name" column, you would use the following code: SORTBY(TableName, "Last Name").

Make Better Decisions
With Data

Analyze data, automate reports and create live dashboards
for all your business applications, without code. Get unlimited access free for 14 days.