Ordering Results With SORT
Sort a spilled range ascending or descending automatically.
Ordering Results With SORT is a free Excel Formulas Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet the SORT Function
Sorting used to mean selecting your data and clicking a button every time it changed. The SORT function does it with a formula instead, so the order updates automatically whenever the source data changes.
SORT is a dynamic array function: you type it once in a single cell and the results spill down (and across) into the cells below. You never have to re-sort manually again.
=SORT(A2:A10)The SORT Syntax
SORT takes up to four arguments:
- array the range or array you want to sort
- sort_index which column (or row) to sort by, counting from 1
- sort_order 1 for ascending, -1 for descending
- by_col TRUE to sort columns side to side, FALSE (the default) to sort rows top to bottom
Only the first argument is required. Leave the rest off and SORT sorts the first column ascending.
=SORT(array, [sort_index], [sort_order], [by_col])A Simple Ascending Sort
Imagine sales figures in A2:A8. To list them smallest to largest, point SORT at the range and accept all the defaults.
The formula spills the sorted values down a fresh column. If a number in A2:A8 changes, the spilled list re-orders itself instantly. No buttons, no menus.
=SORT(A2:A8)Sorting Largest to Smallest
To reverse the order, set sort_order to -1. The first argument stays the same, you just add the descending flag.
This is perfect for leaderboards or top-revenue lists where the biggest values belong at the top.
=SORT(A2:A8, 1, -1)Sorting a Whole Table
SORT is not limited to one column. Pass a multi-column range and the entire table spills out, sorted while keeping each row intact.
Suppose A2:C20 holds Name, Region, and Sales. To order the whole table, use the range as the array.
=SORT(A2:C20)Choosing the Sort Column
When you sort a table, the sort_index tells SORT which column to order by. It counts columns inside the array, not on the worksheet.
For the Name/Region/Sales table in A2:C20, sort by Sales (the 3rd column) from highest to lowest. The whole row travels with its sales value.
=SORT(A2:C20, 3, -1)Sorting Columns Instead of Rows
If your data runs across in a row rather than down a column, set the fourth argument by_col to TRUE.
SORT then reorders the columns left to right instead of the rows top to bottom. This is rare but handy for horizontally laid out data.
=SORT(B1:G1, 1, 1, TRUE)SORT Spills, So Leave Room
Because SORT produces many results from one cell, the cells below and beside it must be empty. If anything is in the way, you get a #SPILL! error.
Type the formula in an open area and let the array land cleanly. Clear out any stray values blocking the spill range.
=SORT(A2:C20, 3, -1)SORT in Google Sheets
Google Sheets has the same SORT function with the same arguments, so your formulas carry over. Sheets also offers an older SORT range menu and a slightly different legacy behavior, but the formula form matches Excel.
One note: in Sheets you can stack several sort keys by adding extra index/order pairs, like sorting by Region then by Sales.
=SORT(A2:C20, 2, TRUE, 3, FALSE)Combining SORT With Other Functions
SORT shines when wrapped around other dynamic arrays. Filter your data first, then sort the result, all in one formula.
Here we keep only East-region rows with FILTER, then sort those by the 3rd column descending. The output is a clean, ordered, filtered list that refreshes itself.
=SORT(FILTER(A2:C20, B2:B20="East"), 3, -1)When the Source Changes
The real payoff of SORT is that it is live. Add a new row to your source range (or use a full-column reference), and the sorted output instantly includes it in the right position.
This makes SORT ideal for reports and dashboards that update as fresh data arrives, with zero manual re-sorting.
=SORT(A2:C100, 3, -1)Quick Check
You want to sort the table in A2:C20 by the third column from largest to smallest. Which formula is correct?
Recap: Sorting With SORT
You learned that SORT orders data with a formula that spills automatically:
=SORT(array)sorts the first column ascending- sort_index picks which column to sort by
- sort_order uses 1 for ascending and -1 for descending
- by_col TRUE sorts columns instead of rows
Leave room for the spill, and wrap SORT around FILTER for ordered, filtered, self-updating lists.
=SORT(A2:C20, 3, -1)Frequently asked questions
Is the “Ordering Results With SORT” lesson free?
Yes — the full text of “Ordering Results With SORT” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.
What will I learn in “Ordering Results With SORT”?
Sort a spilled range ascending or descending automatically. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Excel Formulas Academy?
No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Ordering Results With SORT” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Excel Formulas Academy lesson?
Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Ordering Results With SORT
- Sorting by Another Column With SORTBY
- Generating Numbers With SEQUENCE
- Creating Random Data With RANDARRAY