# Sort Function In Google Sheets

Reading Time: 5 minutes

Master the SORT Function in Google Sheets

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

## 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

1. range:- the data range/group of cells used for the sorting.
2. 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 :
1. Specify the number of the column in the range used for sorting (for eg. 2).
2. A reference of a column within the range used for sorting (for eg. B2:B20).
3. 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.
4. 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.
5. 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

1. 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 Figure 1: Selecting dataset for creating a named range
1. 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. Figure 2: Going to Named Ranges to name our data range

## 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 :
• To sort the dataset by a specific column, using the syntax, use :
• 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: Figure 3: Sorting the dataset using one column in ascending order using the SORT function in Google Sheets

## 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 :
• To sort the dataset by a specific column, using the syntax, use :
• 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: Figure 4: Sorting the dataset using one column in descending order using the SORT function in Google Sheets

## Sorting using multiple columns

• To sort the data range by multiple columns, use the syntax :
• To sort the dataset by multiple columns, using the syntax, use :
• 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: Figure 5: Example of SORT function in Google Sheets where multiple sorts are done in different orders

## Sorting with Column References

• To sort the data range by a column reference, use the syntax :
• Here, I have used :
• 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: Figure 6: Example of SORT function in Google Sheets where column references are used for a specific number of cells of a dataset

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

• To sort the data range horizontally, use the syntax :
• Here I have used:
• 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: Figure 7: Example of sort function in Google Sheets where the dataset is sorted horizontally using transpose function

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.