**Master the SORT Function in Google Sheets**

Learn how to use the Google Sheets SORT function and examples of its variations.

Table of Contents

**What is SORT Function in Google Sheets**

While analyzing your data in Google Sheets, you may need to rearrange data based on a specific dimension – for e.g. arranging customer names alphabetically; arranging revenue in a high-to-low descending order. You may also need a combination of such ascending-descending rules on more than one column. SORT function in Google Sheets can help you with this.

**Syntax of SORT Function in Google Sheets**

=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, …]) |

- range:- the data range/group of cells used for the sorting.
- sort_column:- the column that the data will be sorted by. There are two ways in which you can specify the value in the sort_column parameter :
- Specify the number of the column in the range used for sorting (for eg. 2).
- A reference of a column within the range used for sorting (for eg. B2:B20).

- is_ascending:- Specify True if you want the sorting to be done in ascending order, False if you want the sorting to be done in descending order.
- sort_column2:- use this parameter if you want to sort the data with multiple columns. Specify the number of the column or reference of a column within the range, as done in parameter 2.
- is_ascending2:- similar to parameter 3. Use this only if you want to sort the data range with multiple columns. This parameter will be implemented on sort_column2.

**Naming the data range**

- Selecting the data range:

- We will use a dataset for querying. For ease of querying, we will name the range so we do not need to select the data range every time.
- Click
**Ctrl + A**(Windows) or**Cmd+A**(Mac) to select the entire data range. - Go to
**Data** - Select
**Named Ranges**

- Naming the range:

- Give a suitable name to your data range. Here I am giving it a Dataset.
- Click on Done to complete the process of naming.

**Sorting using one column in ascending order (low-to-high)**

- To sort the data range by a single column in ascending order, use the syntax :

Syntax: =SORT(range, column_index, ascending_order) |

- To sort the dataset by a specific column, using the syntax, use :

=SORT(Dataset,1,TRUE) |

- Here, I have used the named range Dataset as the range to sort.
- I have used column number 1, i.e. Name to sort the dataset.
- I have kept order as Ascending. Therefore, the output is:

**Sorting using one column in descending order (high-to-low)**

- To sort the data range by a single column in descending order, use the syntax :

Syntax: =SORT(range, column_index, ascending_order) |

- To sort the dataset by a specific column, using the syntax, use :

=SORT(Dataset,1,FALSE) |

- Here, I have used the named range Dataset as the range to sort.
- I have used column number 1, i.e. Name to sort the dataset.
- I have kept order as Descending. Therefore, the output is:

**Sorting using multiple columns**

- To sort the data range by multiple columns, use the syntax :

Syntax: =SORT(range, column_index1, ascending_order1, column_index2, ascending_order2) |

- To sort the dataset by multiple columns, using the syntax, use :

=SORT(Dataset,2,TRUE,3,FALSE) |

- Here, I have used the named range Dataset as the range to sort.
- I have used column number 2, i.e. Quarter to sort the dataset in ascending order. In the case of multiple columns, the first column gets the priority for sorting.
- If the Quarter values are the same, the dataset will be sorted using column number 3, i.e. Sales to sort the dataset in descending order, as shown below:

**Sorting with Column References**

- To sort the data range by a column reference, use the syntax :

Syntax: =SORT(range, column_reference, ascending_order) |

- Here, I have used :

=SORT(A2:D20,B2:B20,1) |

- Here, I have used the data between cells
**A2 to D20**as the range to sort. - I have used column reference as
**B2:B20**to sort the data. **Note: The number of columns and rows returned by the SORT function should be the same as the input range, therefore, the column reference also will change if we change the range.**- I have kept order as Ascending. Therefore, the output is:

## Example 5: Horizontal Sorting using Google Sheets Sort function

- To sort the data range horizontally, use the syntax :

Syntax: =transpose(SORT (transpose (range, column_number, ascending_order) |

- Here I have used:

=transpose (SORT (transpose (Dataset), 1, true) |

- The inner
**transpose**is used to transpose the entire dataset, i.e. the columns are replaced by rows and vice versa. - They are then sorted using the SORT function.
- The outer
**transpose**is used to transpose the sorted dataset back to the initial view, as shown below:

**Conclusion**

The SORT function in Google Sheets can be used to sort data as per convenience. Some of the most frequently used applications were discussed in the article. If you want to know more about SORT function in Google Sheets, go through the official documentation here.

**See Also **

You can checkout other equally good articles on Google Sheets here.

How to Create Google Calendar Events from Google Sheets: Learn how to create Google Calendar events from Google Sheets.

ARRAYFORMULA in Google Sheets: Learn how to use the ARRAYFORMULA function in Google Sheets and its variations.

Delete Empty rows in Google Sheets: In this article we would see how to delete empty rows in Google Sheets using two different ways.

How to group rows in Google Sheets: We will learn how to group rows in Google Sheets. We will also have a look at nested grouping.