To sort columns by the values in a row in Google Sheets, select the full range of columns you want to reorder, then choose Data > Sort range > Advanced range sorting options. Turn on Sort left to right, choose the row to use as the sort key, and select ascending or descending order. Include all related rows in the selected range so each column’s data stays together.
What “sort by row” means
Most spreadsheet sorting is vertical: you arrange records from top to bottom according to values in one column. Sorting by row is the horizontal counterpart. It rearranges columns from left to right according to the values across a selected row. For example, you might put a set of monthly sales figures in order from lowest to highest, or arrange project columns by a score recorded in one row.
The phrase can also mean something different: sorting entire records by a field in each record. If a table has one person per row and a column for last name, you normally sort rows by the last-name column. That is the usual top-to-bottom sort, not the left-to-right operation described here. Knowing which arrangement you want helps prevent selecting the wrong range.
- Sort rows by a column: records move up or down; use this for ordinary lists and tables.
- Sort columns by a row: columns move left or right; use this when categories or periods run across the sheet.
Sort columns by a row: step-by-step
In Google Sheets in a web browser, use the sort-range dialog to set the direction and key row. Before sorting, identify the exact block of columns that should move together. If the first column contains fixed labels that should not move, leave it outside the selected range.
- Select the rectangular range containing the columns to rearrange and every row of data that belongs to them.
- Open Data > Sort range > Advanced range sorting options.
- In the dialog, enable Sort left to right. The sort settings should then let you choose a row rather than a column.
- Choose the row whose values determine the order. For a table with a heading row followed by a score row, select the score row as the key.
- Choose ascending or descending order, then apply the sort.
For instance, suppose A1 contains the label “Metric,” B1:E1 contain the months April through July, and B2:E2 contain sales totals 520, 310, 680, and 450. If the month columns are selected as one block, with the labels in column A kept outside it, sorting left to right by the sales row in ascending order puts May (310), July (450), April (520), and June (680) from left to right. The month headings move with their sales values because both rows are part of the selected range.
Check the selected range and the row number in the dialog before confirming. A sort changes the order in place; it does not create a separate sorted copy. If you need the original order for reference, duplicate the sheet or make a copy of the range first.
Choose the right range and keep data together
The most important part of sorting is selecting all the cells that belong to the columns being rearranged. A column in a spreadsheet is not always a single field: it may contain a heading, several measurements, notes, and formulas that all describe the same category. If you sort only the key row, its numbers move but the corresponding labels and other values do not. The result can look plausible while the data relationships are broken.
Imagine a report with product names in A2:A5 and four weekly totals in B2:E5, where each week is a separate column. To order the weeks based on the total row, select the week columns and all their associated product values, but keep the product-name column fixed. If there is a separate total row, include it too when it needs to travel with the weeks. Decide whether the top headings are part of the range and whether they should move with the values.
- Keep fixed identifiers outside the range. A row-label column or descriptive label column may need to remain in place while the data columns move.
- Include every dependent row. Headings, detail values, totals, and notes should move together when they describe the same column.
- Avoid unrelated cells inside the selection. Blank spacer columns or a neighboring table can be rearranged too if they fall within the selected rectangle.
- Review formulas after sorting. Relative references generally adjust as cells move, but a formula’s intended relationship may still be affected by how the range was selected.
If a table has blank rows or columns within the block, do not assume Sheets will infer which nearby content belongs together. Select the intended rectangle yourself and inspect its edges before applying the sort.
Sorting a normal table is different
For a conventional list—one record per row and one field per column—sort the records vertically. Select a cell in the relevant column or select the table range, then use Data > Sort range and choose the column and order. If the table has headings, use the advanced range sorting options and indicate that the data has a header row when appropriate. This tells the dialog not to treat the heading as an ordinary value.
You can also use the sheet-level sort commands in the Data menu when the intent is to sort the sheet by a column. That differs from sorting a chosen range: a range sort affects the selected block, while a sheet sort is meant to reorder the sheet’s records together. Do not sort one column of a multi-column table by itself. Doing so can separate names from addresses, products from prices, or dates from their corresponding events.
A useful way to decide is to ask what should move. If each person, order, or transaction should stay on one line while the lines change position, sort vertically. If each month, category, or scenario occupies a column and those columns should change position, sort left to right.
Ascending, descending, and mixed values
Ascending order generally puts numbers from smallest to largest and text in alphabetical order; descending reverses that direction. Dates sort chronologically when Sheets recognizes the cells as dates. A value that only looks like a date but is stored as text may sort according to its text representation instead, so check the cell values if the order seems unexpected.
For a horizontal sort, the same principle applies across the selected row. Ascending sales totals put lower values first; descending totals put higher values first. If two columns have the same key value, their relative order may not be the order you intended to communicate. Consider whether ties need another criterion, such as a second score row, and whether the dialog offers an additional sort condition for the range and orientation you are using.
Mixed content deserves particular care. Blank cells, numbers stored as text, and formulas returning text can affect the order in ways that are not obvious from a quick glance. If a row combines categories such as “High,” “Medium,” and “Low,” alphabetical sorting will not necessarily represent the ranking you want. In that case, prepare the data or choose a method that reflects the intended custom order rather than assuming alphabetical order means priority order.
Common sorting problems and how to fix them
- “Sort left to right” is not enabled: Reopen the advanced range sorting options and look for the orientation setting. The ordinary sort controls are designed for top-to-bottom sorting.
- Headings move unexpectedly: Review whether the heading row or column belongs inside the selected range and whether the dialog’s header option matches the layout.
- Labels no longer match the numbers: Undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then select the complete block of related rows and columns before sorting again.
- Only one row or column changed: The selection may have covered only the key values. Include the rest of the associated data so it moves as a unit.
- The order looks wrong: Check for numbers or dates stored as text, blanks, inconsistent formats, and values that include leading spaces.
Sorting is not the same as filtering. A sort rearranges the order of cells in the range; a filter temporarily hides records that do not meet criteria and can let you change the visible order. If you only need to inspect high or low values without changing the underlying arrangement, a filter or a separate copy may be a better choice.
Google Sheets compared with Excel
In Google Sheets, the browser-based route for horizontal sorting is through Data > Sort range > Advanced range sorting options, with the left-to-right setting enabled. Excel for Microsoft 365 on Windows has a similar orientation choice, but the path differs: select the range, go to Data > Sort, choose Options, and select Sort left to right. The exact dialog wording and available controls differ between the two programs, so do not follow Excel’s ribbon steps in Sheets.
If you are switching between the apps, verify the selection and sort key rather than assuming the dialogs interpret the range identically. In either program, the underlying concern is the same: sort the full set of related cells and make sure the chosen row or column is the intended key.
When to use another approach
A horizontal sort is useful when the sheet is designed for reading across categories, but it is not always the easiest structure to maintain. If you repeatedly need to sort, filter, compare, or summarize monthly or product data, consider storing each observation as a separate row, with fields such as Date, Product, and Amount in separate columns. That tabular layout works naturally with ordinary sorting and filtering and is usually easier to extend as new observations are added.
For a one-time presentation, sorting left to right can be the simplest solution. For recurring analysis, keeping the source data in a consistent row-based table and creating a separate report view can reduce the risk of disrupting labels or formulas. Make a copy before experimenting if the current order has meaning—for example, if columns represent a planned sequence rather than a ranking.
Frequently Asked Questions
Can Google Sheets sort columns by the values in one row?
Yes. Select the full range to rearrange, open Data > Sort range > Advanced range sorting options, enable Sort left to right, and choose the row and order.
How do I sort a row from smallest to largest?
Select the complete horizontal data block, choose the left-to-right sort option, and use the row containing the numbers as the sort key. Confirm that labels and related values are included so they move with each number.
Can I sort one row without moving the rows below it?
You can select just one row, but that may separate its values from the headings or records they describe. Sort only one row when its cells are independent; otherwise include the related rows in the selected range.
How do I keep the first column in place while sorting horizontally?
Leave that label column outside the selected range, then select the remaining columns and all their related rows. Check the range edges before applying the sort so the fixed labels do not move.
How do I undo a sort in Google Sheets?
Use Ctrl+Z on Windows or Command+Z on Mac soon after sorting. If you have made other edits since then, undo may also reverse those later changes; keeping a copy beforehand is safer for important data.
Related
- IF vs IFS in Google Sheets: Which Formula Should You Use?
- Forward Google Sheets: What Happens When You Share?
- IFERROR Formula in Google Sheets: Syntax and Examples
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Creating a Fillable Form in Word: Steps and Tips That WorkTo create a fillable form in Microsoft Word for Microsoft 365 on Windows, turn on the Developer tab,…
- How to Turn On Track Changes in Microsoft Word DesktopTo turn on Track Changes in Word desktop, open the document, select Review > Track Changes, and then…
- MS Outlook: How to Create a Distribution ListYes. In Microsoft 365 Outlook for Windows, create a personal list from People: in new Outlook, choose People…
- How to Add a Side Header in Microsoft Word DocumentsTo add a vertical side header in Word, open the document’s header, insert a text box, rotate it…
- Translate Google Sheets to English: Formulas, Steps and TipsTo translate text in Google Sheets into English, enter a formula such as =GOOGLETRANSLATE(A2,"auto","en") in an empty cell,…
- Excel Shortcut to the End of Data: Keys and LimitsIn Excel for Microsoft 365 on Windows, press Ctrl+Down Arrow to jump to the edge of the current…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.