There are no definite or built-in ways to sort by row in Google Sheets. All we can do is look for workarounds to sort this unique arrangement of data, a couple of which we will discuss in this article.
Let’s get started.
The Relevance of Horizontal Column Sorting (Sort by Row)
Data in any spreadsheet may not always be organized in the classic table format. We may sometimes see our data arranged in columns (horizontally).
This is because it is easier to lookup data this way. Since the easier to find the data is, the better we can work with it.
Now, sorting this horizontal data becomes even more important as we can get different outcomes when we apply functions like MATCH and HLOOKUP.
2 Ways to Sort by Row in Google Sheets
1. Using SORT and TRANSPOSE Functions
The first, and perhaps the only, way to sort by row in Google SHeets is to use a combination of the SORT and TRANSPOSE functions.
For this scenario, we have created the following worksheet:
As we all know, the SORT function only understands data in the traditional vertical column form. So, to make the function recognize the horizontal arrangement, we take the help of the TRANSPOSE function for the data_range field of the SORT function. The rest of the formula remains as it is.
To sort in the ascending order of the ID, our formula is:
=SORT(TRANSPOSE(C2:G3),1,TRUE)
Another thing to note is that in the horizontal form the column index starts from the top, where traditionally it started from the left.
As you can see, the result of the sort is presented in the classic vertical column format, again since the SORT function was made to work only in this format.
To keep the horizontal arrangement of the table, we have to use another TRANSPOSE function, this time, enclosing the SORT function itself.
=TRANSPOSE(SORT(TRANSPOSE(C2:G3),1,TRUE))
2. Manually Copy-Pasting the Data Transposed (The Longer Method)
The method discussed in the previous section can be performed in a completely basic way. While it does involve a couple of extra steps and gives more freedom to utilize Google Sheets’ built-in options, it can be considered only for very rare occasions. You will see what I mean as we go through the steps.
Step 1: Copy and Paste Transposed.
Select the whole table to copy it and paste it in the desired spot transposed. You can find the Transposed option under Paste Special after you right-click over a cell.
Our transposed copy-paste result:
Step 2: Sort the newly pasted table with any default method.
Google Sheets has multiple built-in options that can be used to sort a regular table. The one that we are going to use is the Sort Range option.
We can open the Sort range options window by right-clicking over the selection and navigating to it.
Right-Click > View more cell actions > Sort range
Step 3: Choose your desired sorting conditions.
In the Sort range options window, you get to choose your sorting options. We have chosen the following:
Our result:
Step 4: Copy and Paste the sorted table transposed.
We copy the newly sorted table and paste it once again using the Paste Special > Transposed option.
Final Words
That should cover the fundamentals and the importance of how to sort by row in Google Sheets. Please feel free to leave any queries or advice you might have for us in the comments section below.
Related Articles for Reading
- How to Apply a Custom Sort in Google Sheets
- Sort by Value in Google Sheets (With Examples)
- How to Sort by Number in Google Sheets (4 Ways)
- Sort by Multiple Columns in Google Sheets (3 Ways)
- SORT Function for Multiple Columns in Google Sheets
- How to Sort Alphabetically in Google Sheets (3 Ways)
- Sort Numerically in Google Sheets (3 Ways)
- How to Sort by Date in a Google Spreadsheet (2 Ways)