Sorting Data in Google Sheets

Sometimes it’s useful to be able to copy data into another range or sheet, sorting it at the same time.

Here’s a sheet containing scores from an online test, which we used in a previous post:

Click image to enlarge

Click image to enlarge

Let’s suppose we want to copy the scores from column A to another column in the same sheet, sorting the scores into ascending order.

The general syntax for the Google Sheets SORT filter is:

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

In this case we don’t need the optional parameters referring to further columns, we’re simply going to use column A. So our sort_column parameter is a range from column A; we’ll use A2:A instead of A2:A14, in case further scores are added later to column A. The range A2:A will select all the completed rows in column A, beginning at A2.

Since we’re only defining a single column in our range, the sort_column parameter will have value 1.

Finally, we want the sorted data in ascending order, so the third parameter has value TRUE:

=SORT(A2:A, 1, TRUE)

Here’s the spreadsheet again, with the sorted data in place:

Click image to enlarge

Click image to enlarge

The second parameter, sort_column, doesn’t have to be a simple column index (like ‘1’ in the above example). You can, if you wish, sort your data according to the values in another range on the sheet, provided you specify the same number of items in the range.

Here’s the same sheet reworked to sort the scores according to the parameter user ID taken from another column:

Click image to enlarge

Click image to enlarge

If you want to sort more precisely, you can add further pairs of parameters for sort_column and is_ascending, and these will be used as subsidiary sort orders in decreasing order of precedence.


Leave a Reply

Your email address will not be published. Required fields are marked *