To gain the most versatility when sorting rows we can use the advanced sort range feature in Google Sheets. This allows us to include header rows and include multiple conditions when sorting.
1. Highlight the data you need to sort
In your data set highlight the cells you wish to sort. This can be achieved by clicking and dragging over the cells.
In our example we wish to sort the rows in the Age column in ascending order, we must ensure this data is included in the selection.
For our demonstration we will select all data in the table including the header rows.
2. Select Data > Sort range > Advanced range sorting options
The advanced range sorting options can be accessed by clicking on Data from the top toolbar followed by selecting Sort range. From the side menu that appears click on Advanced range sorting options.
Alternatively the Advance range sorting options can be accessed by right clicking on the highlighted data. From the displayed menu click on View more cell actions followed by Sort range.
3. Specify the advanced sorting options
A pop up menu will now appear with a variety of range sorting options:
Data has header row: When this option is checked Google Sheets will use the data contained in the header row as an identifier for the sort selection.
Sort by: Clicking this option will display all the columns in the selection. If the data has a header row has been checked the header data will be displayed.
A → Z / Z → A: These select buttons represent the order of the sorted data. A to Z will sort the data in an ascending order. Selecting Z to A will sort the data in a descending order.
Add another sort column: This option allows you to add a secondary sort column.
In our example we have included the header row and we want to sort by the age column in an ascending order. To achieve this we first check the box next to Data has header row, then we will select age from the Sort by dropdown menu. Finally we will ensure the button next to A → Z is selected.
4. Select Sort to see the results
Click on the Sort button in the advanced sorting options window. This will sort your rows to your specified conditions.
In our example we can now see that all the age data has been sorted in an ascending order whilst retaining the header column.
Sort by Row Google Sheets (Basic Method)
There is a more basic method to sorting rows in Google Sheets. This method is efficient but has limitations over the advanced sort method. It cannot distinguish the header row and only a basic sort of A-Z or Z-A can be performed.
1. Select the exact data to be included in the sort
Select only the data you want to sort.
Note: if you have a header row do not include this as it will be sorted as standard data.
In our example we will now order the name data in a descending order. As our data set contains a header we will not include this in the selection.
2. Click on Data > Sort range > Sort range by column (Asc/Desc)
From the top toolbar select Data followed by Sort range. A side menu will appear with the following options:
Sort range by Column (A to Z): Sorts the selected rows in an ascending order.
Sort range by Column (Z to A): Sorts the selected rows in a descending order.
In our example we have selected data from Column B which displays in our sort range options. As we want to order our data in a descending order we will click Sort range by Column B (Z to A).
3. See the results
After clicking on the relevant sort option the selected data is sorted.
In our example we can see the selected rows under the Name header have been sorted by descending order.