Sort horizontally in Google Sheets (Sorting columns from left to right)

Have you ever encountered a situation where you needed to sort data horizontally in Google Sheets? By default, Google Sheets provides a built-in feature to sort data vertically (from top to bottom). But what if you want to sort data organized horizontally, from left to right? Unfortunately, there is no built-in function in Google Sheets for horizontal sorting (sorting by columns instead of rows). However, there are ways to achieve it.

Horizontal sorting using the SORT function

You can employ some formula magic to sort data horizontally in Google Sheets. Although the SORT function alone can only sort data organized vertically, you can combine it with the TRANSPOSE function to convert horizontal data into vertical data.

Let’s say you have a dataset like the one shown below, and you want to sort this data based on the students’ grades.

The following formula will sort the data horizontally in Google Sheets:

=TRANSPOSE(SORT(TRANSPOSE(B1:K2),2,))

Copy the Google Sheets data

The above formula uses the TRANSPOSE function to transpose the data from horizontal to vertical. It then utilizes the SORT function to sort this data based on the second row (which becomes the second column in the transposed data). The result of the SORT function is once again used in the TRANSPOSE function to obtain the sorted horizontal data.

One advantage of using a formula is that the resulting data is dynamic. This means that if you change any of the values in the original data, the result will automatically adjust to display the newly sorted data.

Horizontal sorting by manually transposing data

If you don’t need the original data, you can also manually transpose the data, sort it (just like you would with a range of vertical cells), and then transpose it again to get the sorted horizontal data.

Let’s assume you have a dataset like the one shown below, and you want to sort this data based on the students’ grades.

Here are the steps to sort this data horizontally:

  1. Select the entire horizontal dataset that you want to sort.
  2. Copy the data.
  3. Go to an empty cell (in the same or different sheet).
  4. Right-click and hover over the “Paste special” option.
  5. Click on “Transpose”.

The above steps will give you the transposed data (as shown below), which you can easily sort using the built-in sorting feature in Google Sheets.

To sort the transposed data, follow these steps:

  1. Select the entire dataset.
  2. Click on the “Data” option in the menu.
  3. Click on “Sort range”.
  4. In the Sort range dialog box, check the “Data has header row” option.
  5. Select “Score” as the column to sort by.
  6. Click on “Z to A” (if you want to sort the data in descending order).
  7. Click on “Sort”.

Now that you have the sorted data, you can once again copy and paste it as transposed data, which will give you the same result as sorting the data horizontally in Google Sheets.

These are two ways to sort data horizontally in Google Sheets. In most cases, I would prefer using the formula method as it is easier to use. If you are unable to use a formula, you can resort to the transpose paste method for horizontal sorting.

Note: If possible, try to consider transforming horizontal data into vertical data. This makes it easier to maintain and use the data since most formulas and functionalities in Google Sheets are designed to work with vertical datasets.

I hope you found this tutorial helpful! To learn more about Google Sheets, visit Crawlan.com.

Related posts