It’s always easier to work with data that has been organized and sorted in a particular order.
They are easier to sift through and it’s easier to find data items of interest.
This is why the Sort Function Google Sheets has built-in is so great. Follow along with this guide to learn how to sort in Google Sheets.
What Is the Sort Function in Google Sheets Used For?
As the name suggests, the SORT Google Sheets function helps us sort data in a range of cells and returns the sorted output in a new cell range.
This function lets us sort data in ascending or descending order. It also lets us sort data by one or multiple column criteria.
Types of Sorting – The Difference Between Sort Menu and SORT Function
Google Sheets provides two ways to sort data:
- Using the ‘Sort’ menu (can be found under the ‘Data’ menu).
- Using the Google Sheets SORT formula function
While the Sort menu can be accessed with a couple of clicks, the SORT function lets you enter the formula in the formula bar, giving you more control over the sorting process.
The main difference between the above two methods is that the Sort menu works on and changes the original data range.
The SORT function, on the other hand, displays the sorted data into a new data range, thereby keeping the original data unchanged.
alphabetically, or any other ascending or descending order.
You can use these methods to sort by date alphabetically, or in any other ascending or descending order.
How to Sort a Google Sheet in Entirety
You can use the sort menu to sort an entire sheet simply:
- Select the column header of the column you wish to sort the sheet by.
- Navigate to Data > Sort sheet
- Select how you’d like to sort the sheet.
Syntax of the Sort Function in Google Sheets
The syntax for a SORT formula in Google Sheets is:
SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, …])
- range is the group of cells that you want to apply the sort function on (the cells that you want to sort)
- sort_column is the main column by which you want to sort the data in the range.
- is_ascending specifies if the range should be sorted in ascending or descending order of the sort_column. It can either be TRUE or FALSE, with a FALSE representing a ‘descending’ order.
The above three parameters are compulsory in a SORT function, but you can also add additional parameters if you want to sort the range by more criteria. In that case,
- sort_column2 is the secondary column by which you can sort the data in range
- is_ascending2 specifies if we want to sort the range in ascending or descending order of sort_column2. This parameter can also be a TRUE / FALSE value.
You can add more [sort_column2, is_ascending2] pairs like this depending on the number of column criteria you need for sorting your data in the range.
Note: The sort_column can be specified either as a column index (a number representing the position of the column in the range), or as a reference (the range of cells in the column, eg: A2:A5). The number of cells in sort_column should be equal to the number of rows in the range, otherwise, the SORT formula returns an error.
How to Sort in Google Sheets With the SORT Function (Examples)
Once you understand the syntax for the =SORT Google Sheets function, applying it is quite easy.
We will take a look at two ways in which you can use the Google Spreadsheet SORT function:
- When you want to sort by a single column
- When you want to sort by multiple columns
You can also sort by row instead.
To explain both methods of sorting in Google Sheets, we will use the following sample data. We are going to use the SORT function to sort the data shown below:
To help you easily see the differences between the original and sorted data, we are going to sort the above data and display it in the same sheet (in a neighboring cell range).
However, you can even enter the SORT formula in a new sheet and display the sorted data there.
Google Sheets Sort by Number Ascending With a Single Column Argument
When you want to sort by a single column, just the first three parameters of the SORT function are enough to get the job done.
From our sample data, say we want to sort all the rows by Company Name (which is column A). Sorting on Google Sheets in this way is easy. Here’s how you can display the sorted data range starting from cell F2.
- Copy the data column headers and paste it onto the first row (cells F1 to I1 in our example).
- In cell F2, type following formula:=SORT(A2:D8,A2:A8,TRUE) or =SORT(A2:D8,1,TRUE).
- Press the return key
You should now see the entire sorted data occupy the range from cell F2 to I8. Note that the result of the SORT function is dynamic.
So, any changes you make to the original data get reflected in the sorted output as well.
Also, note that you cannot make any changes to the sorted output. Attempting to do so will result in a #REF error.
The Google Sheets Sort Function with Multiple Columns
If you look at the sorted data now, you will notice that some of the company names are repeated.
If you also want to ensure that the rows get further sorted by, say, decreasing order of Delivery date, whenever there’s a company name repeating, the SORT function makes that really easy too.
In this case, you can introduce the additional parameters into the SORT function. Here’s how to custom sort in Google Sheets with multiple parameters:
In the above formula, we added two new parameters:
- We set sort_column2 to the column C2:C8 (The Delivery Date column)
- We set is_ascending2 to FALSE, since we want to sort in descending order of Delivery Date
This gives the following result:
You’ll notice in the above figure, that the data is first sorted in alphabetical order of Company Name.
Whenever there is a repetition of a name, the rows containing the repeated company names are then sorted in descending order of Delivery date.
For example, the company name Krajcik-Lowe appears in three rows. These rows are then sorted with the latest dates appearing first and the older dates appearing last.
You can even further refine this search if you need to, by adding more [sort_column2, is_ascending2] parameters.
How Many Columns Can I Sort?
You can add as many parameters and arguments to your columns as you’d like. In the above example, we used two SORT arguments to sort the data. You could use 3 or more with TRUE or FALSE parameters to further sort the data too.
Google Sheet Sort by Value FAQ
Can You Custom Sort in Google Sheets?
You can only sorry from lowest to highest (A-Z) or highest to lowest (Z-A) in Google Sheets. But, you can set parameters for the SORT function from different columns for a custom sorting.
How Do You Sort in Google Sheets but Keep Rows Together?
- Select a cell in the column you wish to sort by
- Highlight the entire range by clicking and dragging from the initial cell
- Navigate to Data > Sort range and select the order you wish to sort by
How Do You Sort Data in Google Sheets?
The simplest way is with the sort menu:
- Highlight the data you wish to sort
- Click Data > Sort (sheet or range) and choose how you wish to sort the data
How Do I Sort From Highest to Lowest in Google Sheets?
Here’s how to sort from highest to lowest in Google Sheets:
- Select the range you wish to short
- In the sort menu (Data > Sort) select Sort by column X Z-A.
How Do I Create a Custom Sort Order in Google Sheets?
You can use the SORT function instead of the sort menu for custom sorting.
The SORT function uses the following syntax:
SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, …])
Sort Me Out With More Learning
In this tutorial, I showed you how to sort in Google Sheets using single or multiple-column criteria.
The SORT function can be really helpful if you want to quickly sort and browse through your data, without having to affect the original data.
We hope this tutorial has been helpful to you.
Other Google Sheets tutorials you may like: