SORT Function in Google Sheets

The SORT function lets you sort a range (or array) of data. The function creates a new range of data with the new, sorted output from the function. Spreadsheet users often use SORT with or instead of the FILTER function when widdling down large amounts of data. FILTER is for reducing data, and SORT is for sorting it.

If you find yourself nesting functions from the filter family (FILTER, SORT, SORTN, UNIQUE), consider using the QUERY function instead. QUERY is a more complicated function but can be easier to use than nested filter functions.

You typically access the SORT function from the user menu, but you can also type it into a cell just like any other function.

Video Explanation

Thumbnail showing screen shot of SORT function
YouTube Video Explaining the SORT Function

Purpose

Returns sorted data from your specified source.

Syntax

=SORT(range,sort_column,is_ascending,[sort_column2, is_acending2,...])

  • range – The entire range of data that is to be sorted
  • sort_column – The column of data that contains the criteria that you are sorting. It can only be one column at a time.
  • is_ascending – Two possible answers – TRUE for ascending (1,2,3), FALSE for descending (3,2,1)

Tip: This function writes the output in, below, and to the right of your starting point. The formula text will remain in the upper-left cell.

Examples

Example 1

This first example uses a simple SORT function with one column of data to be sorted in ascending order. The first rows are your raw data, then the rows below the SORT formula are the output. This table shows the starting data and the formula typed into the last cell.

 A
12
25
33
4=SORT(A1:A3,1,TRUE)
5 
6 

Shows the starting data and the formula typed into the last cell.

 A
12
25
33
42
53
65

The first three rows are the original data, and the last three rows are the dynamic results of the function. The function is still in cell A4, and you can see it if you select that cell.

Example 2

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.

  A B
1 2 b
2 5 t
3 3 r
4 =SORT(A1:B3,2,FALSE)
5    
6    
  A B
1 2 b
2 5 t
3 3 r
4 5 t
5 3 r
6 2 b

The first three rows are the original data, and the last three rows are the dynamic results of the function. The function is still in cell A4, and you can see it if you select that cell.

Example 3

Two-column SORT, sorted by only column 2 in ascending order.



Shows the starting data and the formula typed into row 7.
  A B
1 Huey Duck
2 Dewey Duck
3 Louie Duck
4 Duckworth Butler
5 Bubba Caveduck
6 Tootsie Triceratops
7 =SORT(A1:B6,2,TRUE)
8    
9    
10    
11    
12    

The first six rows are the original data, and the last six rows are the dynamic results of the function. The function is still in cell A7, and you can see it if you select that cell.
  A B
1 Huey Duck
2 Dewey Duck
3 Louie Duck
4 Duckworth Butler
5 Bubba Caveduck
6 Tootsie Triceratops
7 Duckworth Butler
8 Bubba Caveduck
9 Huey Duck
10 Dewey Duck
11 Louie Duck
12 Tootsie Triceratops

Example 4

Lastly, we have a two-column SORT, sorted by column 2 in ascending order then by column 1 in ascending order. Now Dewey comes before Louie.

Shows the starting data and the formula typed into row 7.


  A B
1 Huey Duck
2 Dewey Duck
3 Louie Duck
4 Duckworth Butler
5 Bubba Caveduck
6 Tootsie Triceratops
7 =SORT(A1:B6,2,TRUE,1,TRUE)
8    
9    
10    
11    
12    
The first six rows are the original data, and the last six rows are the dynamic results of the function. The function is still in cell A7, and you can see it if you select that cell.
  A B
1 Huey Duck
2 Dewey Duck
3 Louie Duck
4 Duckworth Butler
5 Bubba Caveduck
6 Tootsie Triceratops
7 Duckworth Butler
8 Bubba Caveduck
9 Dewey Duck
10 Huey Duck
11 Louie Duck
12 Tootsie Triceratops

Live examples in Sheets

Go to this spreadsheet for several examples of the SORT function that you can study and use anywhere you would like.

Leave a Comment