Sort Function in Google Sheets: A Practical Quick Guide
Learn how to sort data efficiently in Google Sheets using the SORT function. This practical, step-by-step guide covers single-column and multi-column sorts, dynamic ranges, common pitfalls, and real-world templates to streamline your workflow.

You can master sorting in Google Sheets with the SORT function, which reorders a range by one or more sort columns in ascending or descending order. This quick guide covers syntax, single- and multi-column sorts, and how to sort by rows or columns without altering the original data. By the end, you’ll apply dynamic sorts to any dataset.
What is the sort function in Google Sheets?
The sort function is a powerful tool that rearranges the rows (or, with the by_col flag, the columns) of a given range based on one or more sort keys. Unlike manual sorting, SORT returns a new, sorted array that you can place elsewhere in your sheet. This keeps your original data intact while presenting a reordered view for analysis, reporting, or sharing. In practice, sorting is essential for preparing data before building summaries, dashboards, or pivot tables. The phrase sort function google sheets captures the core capability: reordering data programmatically to reveal trends and improve readability across tasks such as budgeting, student records, or project tracking.
For students, professionals, and small business owners, mastering this function means less manual clicking and fewer errors when datasets grow. You’ll learn to sort by a single criterion, then extend to multiple keys, and finally explore sorting by rows (columns) for different layouts. As you read, keep in mind that sorting does not permanently alter your source data unless you copy the results back over the original range.
Basic syntax and how parameters work
The typical form of the SORT function is:
- range: the data to sort (e.g., A2:C100)
- sort_column: the 1-based index of the column in range to sort by (e.g., 2 for the second column)
- is_ascending: TRUE to sort ascending or FALSE for descending
- additional_sort_columns and orders: you can pass additional pairs (sort_index, is_ascending) to sort by more than one column
- by_col (optional): TRUE to sort by columns instead of rows
Example to sort by the second column ascending: =SORT(A2:C100, 2, TRUE). If you want to sort by two columns (second column ascending, first column descending): =SORT(A2:C100, {2,1}, {TRUE,FALSE}). The by_col parameter defaults to FALSE, meaning the sort applies to rows. This flexibility makes SORT useful across budgets, rosters, or inventory lists.
Related topics include how to combine SORT with FILTER for dynamic views and how to anchor ranges using named ranges for easier maintenance.
Sorting by a single column: practical example
Suppose you have a list of sales entries in A2:C100 with columns: Date, Salesperson, Amount. To sort by Amount from smallest to largest, place the formula in a new area: =SORT(A2:C100, 3, TRUE). If you want to sort by Amount but break ties by Date (earlier dates first), you can use a two-column sort: =SORT(A2:C100, {3,1}, {TRUE, TRUE}). This returns a sorted view where Amount drives the order and Date serves as a secondary criterion. Practice with your own data to see how the rows reflow as you modify the order flags.
Sorting by multiple columns: how to sort by two keys
When sorting by multiple columns, you pass multiple sort keys. For example, to sort a course roster by Grade (column 3) ascending and then by Last Name (column 2) ascending, you’d use: =SORT(A2:C100, {3,2}, {TRUE, TRUE}). Sorting by multiple keys ensures consistent ordering even when the primary key has duplicates. You can extend this pattern to three or more keys by adding pairs to the arrays. Always test with a small subset to confirm the output aligns with expectations.
Sorting by rows vs. sorting by columns: the by_col flag explained
By default, SORT sorts rows. If you want to sort data by columns (i.e., reorder the columns themselves based on a header, for instance), you add the by_col parameter at the end as TRUE: =SORT(A2:Z200, 2, TRUE, TRUE). This is handy for rearranging a dataset layout for a report where column order matters more than row order. Note that sorting by columns can dramatically change the meaning of the data, so use it when you truly need a column-centric view.
Common pitfalls and how to avoid them
- Excluding header rows from the range can produce a confusing result; reserve headers in a separate row and skip them in the SORT range.
- When you insert the SORT formula, ensure the destination area is large enough to accommodate the entire output; otherwise, you may see #REF! errors.
- Using array constants like {2,1} without corresponding {TRUE, FALSE} can sort unexpectedly if you forget the ascending/descending order. Always pair them correctly.
- If your data updates, SORT will dynamically reflect changes, which is powerful but can overwrite if not placed in a proper destination.
Real-world use cases and templates
Common sorting scenarios include organizing budget line items by amount or date, sorting student rosters by last name then first name, and arranging product inventories by category and then by quantity. For templates, set up a standard range (e.g., A2:D200) and use named ranges for the sort range to simplify reuse across reports. Combine SORT with QUERY to extract sorted subsets based on criteria, or with IMPORTRANGE to sort data pulled from other sheets for a consolidated dashboard.
Alternatives and related functions you should know
- SORTN lets you return a limited subset of sorted results, which is helpful when you only want the top N entries.
- FILTER combined with SORT creates dynamic views of your data based on criteria while maintaining a sorted order.
- The QUERY function can express sorting as part of a broader SQL-like query when you need more complex filtering.
- For text-based orders, TEXT() formatting can improve readability after sorting.
These tools complement SORT and let you build robust data workflows in Google Sheets.
Tools & Materials
- A computer or device with Google Sheets access(Stable internet connection; Google account signed in)
- Sample dataset(Include at least 3-5 columns with headers)
- Spreadsheet with headers(Place the SORT output starting in an empty area)
- Optional: named ranges(Simplifies reuse of sort ranges in multiple sheets)
- Keyboard shortcuts cheat sheet(Boost speed when editing formulas)
Steps
Estimated time: 20-30 minutes
- 1
Prepare your data
Inspect the dataset and ensure headers are clearly defined. Decide which range you want to sort and whether you want the result to appear in a new area or overwrite part of your sheet. Remove any non-tabular rows that could distort the sort order.
Tip: Exclude header rows from the sort range to keep headers intact; you can reference the data area (e.g., A2:D100) while headers stay in A1:D1. - 2
Write your first SORT formula
Choose a destination cell and enter a basic SORT formula, such as =SORT(A2:C100, 2, TRUE). This sorts by the second column in ascending order. Verify the result updates when you modify the source data.
Tip: Start with a simple sort to confirm the range and indices are correct before layering multiple sort keys. - 3
Sort by multiple columns
Extend to multi-key sorts by supplying additional sort indices and orders, e.g., =SORT(A2:C100, {2,1}, {TRUE,FALSE}). This sorts by column 2 ascending, then column 1 descending. Adjust for your dataset structure.
Tip: When using arrays, ensure the braces and commas are correctly placed to avoid syntax errors. - 4
Try sorting by rows or using by_col
If you need to sort by columns instead of rows, add the by_col parameter: =SORT(A2:Z200, 2, TRUE, TRUE). This rearranges columns based on the second row or header values depending on context.
Tip: Use by_col only when your data structure requires column reordering; it changes how the data is interpreted. - 5
Validate results and edge cases
Double-check that the sorted results maintain data integrity, especially when there are duplicate sort keys. Consider using a helper column to stabilize sort order if necessary.
Tip: If duplicates occur, use a secondary sort key to ensure deterministic results. - 6
Document and test with templates
Create a small, reusable template that includes the range, sort keys, and destination. Test the template with different datasets to confirm consistent behavior.
Tip: Document notes in the sheet about which columns drive the sort and why, so teammates can reuse the approach.
FAQ
What is the sort function in Google Sheets?
The SORT function rearranges a range of data based on one or more sort keys, returning a sorted array while leaving the original data intact.
SORT rearranges data and returns a new sorted view without altering the source.
How do you sort by multiple columns in Google Sheets?
Pass multiple sort indices and orders, e.g., =SORT(A2:C100, {2,1}, {TRUE,FALSE}). This sorts by column 2 ascending, then column 1 descending.
Use multiple sort keys to define a clear order, like second column ascending and first column descending.
Can SORT modify the original data?
No. SORT returns a sorted view as a new array. If you want to replace data, you must copy the results back to the original range.
SORT creates a new sorted view without changing the source data.
What's the difference between SORT and FILTER for sorting?
SORT reorganizes data order; FILTER selects rows meeting criteria. You can combine them, using FILTER to subset and SORT to order the results.
FILTER picks what you see; SORT orders what you see. Use together for dynamic reports.
How do I sort by date in Google Sheets?
Treat the date column as a sort key (e.g., 3) and set is_ascending to TRUE. For complex cases, combine with a secondary key.
Sort by the date column, usually as the primary key, to get chronological order.
What are common mistakes when sorting?
Mistakes include sorting headers, using ranges that change with data growth, and ignoring the impact of duplicates. Use a stable range and test with new data.
Be careful with headers and dynamic ranges; test sorts with new data first.
Watch Video
The Essentials
- Learn how to implement SORT for single- and multi-column sorts
- Understand how to control ascending vs. descending order
- Know when to sort by rows vs. by columns using by_col
- Apply templates to automate repetitive sorting tasks
