Sorting is one of the most fundamental skills all spreadsheet users should learn.
There are a couple of ways to sort data in Google Sheets. You can sort through the data menu, or use the sort function.
In this tutorial, I will show you how to use the sort function to sort through your data in Google Sheets.
Table of Contents
- 1 What is the SORT Function?
- 2 Syntax of the SORT Function
- 3 SORT Formulas
- 4 How to Use the SORT Function
- 5 Closing Thoughts
What is the SORT Function?
The SORT function is a formula that can be used to sort through your data in Google Sheets.
The SORT function can sort your data by a specific column or multiple columns.
You can sort data numerically or alphabetically in ascending or descending order.
One of the main benefits of sorting with the SORT Function instead of sorting using the data tab is that the formula is dynamic. As your data changes, so will your sorted values will automatically be sorted according to the rules you have specified in the syntax.
If you sort by using the data tab, it is static. This means you will need to resort every time your data changes.
Syntax of the SORT Function
This is the syntax of the SORT Function
SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, …])
- range is the cells that you want to sort. You will need to select the cell references of the data that you want sorted
- sort_column is the column that you want the data to be sorted by, you will be using a number here to specify which column to sort by (1 for the first column, 2 for the second. etc…)
- is_ascending will tell Google Sheets whether to sort the data in ascending or descending order. You will be using values of TRUE or FALSE here. TRUE sorts in ascending order, FALSE sorts in descending order.
- [sort_column2, is_ascending2, …] means that you can add additional sorting parameters if you want to sort by additional criteria. The function will first sort your range by the first parameters and then sort by the second set of parameters. You can continue to add additional parameters as desired
The syntax that we covered above can seem a little overwhelming at first because there are a number of ways to structure your formula depending on you are trying to sort the data.
Here are a few common examples and the syntax associated with these sorting rules.
Sort by a Single Column in Ascending Order
- =SORT(A1:A15, 1, TRUE)
Sort by a Single Column in Descending Order
- =SORT(A1:A15, 1, FALSE)
Sort by Multiple Columns in Ascending Order
- =SORT(A1:B15,1,TRUE, 2, TRUE)
Sort by Multiple Columns in Descending Order
- =SORT(A1:B15,1,FALSE, 2, FALSE)
How to Use the SORT Function
Sorting a Single Column
If you just have a single column of data you are trying to sort, here is what you do:
- Select the cell where you want the sorted data to appear
- Type =SORT
- Select the range of cells you want to be sorted.
- To sort by ascending order just add a closing parenthesis “)” to close your formula and press ENTER
- To sort by descending order add a “1, FALSE” before adding your closing parenthesis and pressing ENTER
Sorting by a Single Column
In this example, I will be sorting a table with 3 columns to sort by the third column in ascending order.
Here are the steps
1. Selected the cell where you want the sorted table to appear and type “=SORT”. Press Tab on your keyboard to begin entering in the function.
2. Select the range of cells that you want sorted and then type a comma (,)
3. Type the number corresponding to the column you want to sort by and then add a comma (,). In this example I want to sort by the third column (sales) so I placed a 3 here.
4. To sort by ascending order type TRUE, to sort by descending order type FALSE. Ater this add your closing parenthesis “) and press ENTER
5. Your selected data will now be sorted according to the column you have selected
Sorting by Multiple Columns
If you want to sort by multiple columns you can add additional sorting parameters to your function depending on which way you want to sort the data.
If we use the previous example, in column B I have district, and column C I have sales.
Maybe I want to sort my data first by column B so that I can group together who is in each district and then by column C to see who sold the most in each district.
That can be done by adding the additional parameters to your SORT function like this:
The first set of parameters (2, TRUE) will first sort by the 2nd column in ascending order and the second set of parameters (3, FALSE) will sort by the third column in descending order.
The SORT function is a powerful feature that has many uses. Learning how to string together sorting rules to analyze your data efficiently will definitely come in handy if you take the time to learn it.
Again, the main advantage of using this function over sorting through the data tab is that your sorted range is dynamic. As your data changes, so will your sorted values.