How to sort in Google Sheets and keep rows together
Sorting data is a fundamental task when working with spreadsheets, and Google Sheets provides powerful sorting capabilities. However, one common challenge users face is sorting data while keeping related rows together. In this blog post, we will explore various techniques to effectively sort data in Google Sheets while maintaining the integrity of your data relationships.
Here we have a dataset related to customer purchases. It contains information about customers such as Customer ID, Age, Gender, Purchase Amount, Product Category and Date of purchase. Here we will sort Age in ascending order while keeping the rows together. Let’s have a look at the dataset first.
Method – 1 Using Sorting options
Step – 1 Select the dataset.
- Click on Data tab.
- In the menu opened, open the side menu of Sort Range.
- In the Side Range side menu select Advanced range sorting options.
Step – 2 Apply the Sorting.
- Once you open Advanced range sorting options, a sorting menu will appear.
- Check the box of Data has header row.
- Select the column you want to paste the sorted dataset from the Sort By dropdown menu.
- Choose A -> Z for sorting in ascending order and Z -> A for sorting in descending order.
- Click on Sort.
Method – 2 Using Sorting formula.
This sorting formula makes a copy of the original dataset but in sorted form. Therefore, if you want to keep the original data as it was and want the sorted data in another sheet or another place in the same spreadsheet then this method is preferable.
Step – 1 Type the formula.
- Type the formula in cell where you want all of your sorted data to appear.
- The formula syntax is:
SORT(Range_of_cells, Index_of_column_to_sort_the_dataset_accordingly, TRUE/FALSE (TRUE for ascending order and FALSE for descending order ) )
- In our case formula will be:
SORT(A2:F11, 2, TRUE)
This formula tells Google to sort the data range from A2:F11 with respect to column 2 in the data range in ascending order. In our case, the data will be sorted according to the Age column in ascending order.
Step – 2 Apply the formula.
- After typing the formula hit Enter.
- All the sorted data, sorted according to the Age column in ascending order, will appear in the new place as shown in the image.