How to Sort Data in Google Sheets

If you work with data in Google Sheets, sorting is a feature you would need quite often.

In this tutorial, you'll learn how to sort data in Google Sheets.

Sort Data in Google Sheets

Suppose you have students marks data in a Google Sheet as shown below:

Sort Data in Google Sheets - Data Set 1 column

Now you can sort this data with names in an alphabetical order or marks in an ascending order.

Sorting Names in an Alphabetical Order

Here are the steps to sort the names in an alphabetical order:

  • Select the entire data set (A1:B11).
  • Right click anywhere in the selection and click on Sort Range.Sort Data in Google Sheets - Sort Range
  • In the Sort Range dialog box:
    • Check the box for ‘Data has header row'.Sort Data in Google Sheets - Data has Header row
    • Select the column for which you want to sort. In this case, it's the Names column.Sort Data in Google Sheets - sort by column
    • Click on Sort button.Sort Data in Google Sheets - sort button

This will sort the names in an alphabetical order (along with the numbers).

Sort Data in Google Sheets - sorted data names

The same way, you can also sort based on the marks. In that case, you need to select marks as the column to be used for sorting.

Multilevel Sorting

Suppose you have a similar data set, but now, you have the marks for each student for three tests (Test 1, Test 2, Test 3).

Sort Data in Google Sheets - three tests

Now you can do a multi-level sorting with this data set. In this case, you can first sort the data by name and then by Test.

That will group all the three test scores for each student.

To do this:

  • Select the entire data set (A1:C31).
  • Right-click anywhere in the selection and click on Sort Range.Sort Data in Google Sheets - multilevel - right click
  • In the Sort Range dialog box:
    • Check the box for ‘Data has header row'.Sort Data in Google Sheets - multilevel - data header
    • Select the column for which you want to sort first. In this case, it's the Names column.Sort Data in Google Sheets - multilevel - names
    • Click on ‘Add another sort column'.Sort Data in Google Sheets - multilevel - add another
    • In the ‘then by' drop down, select Test.Sort Data in Google Sheets - multilevel - test
    • Click on Sort.Sort Data in Google Sheets - multilevel - sort button

This will sort the data first by the names and then by the test name.

Sort Data in Google Sheets - multilevel - result

Note: If you want to keep the original data intact, make a copy and then perform the sorting on the copied data.

Sort Data in Google Sheets using the SORT Function

Google Sheet has a wonderful function that makes the sorting easy as pie – the SORT function.

Suppose you have the data set as shown below:

Sort Data in Google Sheets - Data Set 1 column

 

To sort this data using the SORT function, in cell C2, enter the formula: =SORT(A2:B11,1,TRUE)

As soon as you enter this formula and hit enter, it would automatically give you a sorted data range (as shown below):

Sort Data in Google Sheets - sort function

Here is how it works:

SORT function takes three arguments in the formula:

  • The range (A2:B11) which is to be sorted
  • The column based on which the sorting is to be done. In this case, it is column 1.
  • The order (ascending or descending). If this argument is TRUE, it sorts in the ascending order.

Note that you can sort multiple columns as well. In that case, you need to supply the column number and the sorting order.

Here are a few things you need to know before you use the SORT function in Google Sheets:

  • You can not delete a part of the result. If you have to delete it, you need to delete the entire result of the SORT function.
  • If there are any filled cells in the range that would be taken up by the SORT function, it would return an error.

You May Find the following Google Sheets Tutorials:

>