The SORT function lets you sort a range of data in Google Sheets. It is similar to the sort options found in the menus but leaves the source data unsorted.
The function creates a new dynamic range of data with the sorted output from the function.
💡If you find yourself nesting functions from the filter family (FILTER, SORT, SORTN, UNIQUE), consider using the QUERY function instead. QUERY is more powerful and easier to use than nested filter functions.
Returns sorted data from your specified source.
range– The data to be sorted
sort_column– The column containing the criteria you are sorting.
is_ascending– Two possible answers – TRUE for ascending (1,2,3), FALSE for descending (3,2,1)
FILTER – Outputs a filtered range of data
SORTN – Sorts a range of data and returns the first n items
UNIQUE – Outputs data with duplicates removed
QUERY – A flexible function that can filter output
Example 1 – A Simple Ascending Sort
This first example uses a simple SORT function with one column of data sorted in ascending order.
The formula in cell
B5 points to the
B1:B3 for the unsorted data. The
1, which is column
is_ascending input tells the function to rearrange the data from smallest to largest, which is why the output is
Example 2 – A Two-Columns Range
Let’s look at an example now of sorting a table with two columns of data and sorting in descending order with the second column as the value to sort by.
The first three rows are the original data, and the last three are the function’s dynamic results. The function is still in cell
B5, and you can see it if you select that cell. Since Google Sheets used the second column, Google Sheets sorted those values in backward alphabetical order –
💡 This function’s output can spill below, and sometimes to the right, of its cell.
Example 3 – Sorting by Two Columns
Lastly, we have two columns sorted by column
2 in ascending order and then by column
1 in ascending order.
Notice that the data is now sorted by the last name, but also Dewey comes before Huey and Louie.
Live Examples in Sheets
Go to this spreadsheet for several examples of the SORT function that you can study and use anywhere you want.