SORT
Sort a range dynamically, in a formula, without touching the sort menu. As source data changes, the sorted output updates instantly. The foundation of modern Excel dashboards and live reports.
Returns a sorted version of the input array. Sorts by any column, ascending or descending, dynamically. Never modifies the original data.
What SORT does
SORT returns a sorted copy of a range. Traditional sorting in Excel is a one-time action — you click Sort, choose ascending or descending, and the rows rearrange in place. If new data arrives, you have to sort again. SORT changes that. It's a formula that maintains a sorted view of your data continuously. Add a new row, edit an existing value, delete an entry — the SORT output updates automatically.
SORT preserves your source data. The original range stays in its original order; SORT produces a new sorted array in a different location. This makes it perfect for dashboards and reports where you want the raw data preserved for auditing but a sorted view for presentation.
💡 SORT vs SORTBY — quick distinction
SORT uses a column INSIDE the array as the sort key. Sort by column 2 of the returned range. Simple, elegant, common. SORTBY uses an EXTERNAL column as the sort key — sort range A by values in range B. Useful when the sort key isn't part of the output.
Syntax breakdown
The range or array to sort. Can be a single column, a single row, or a multi-column/row range. SORT preserves the structure and reorders rows (or columns, if by_col is TRUE).
Which column (or row) to sort by. Column 1 is leftmost, column 2 is next, etc. Default is 1. If your array has one column, this can be omitted.
1 ascending (default) — A to Z, small to large. -1 descending — Z to A, large to small. Any other value is an error.
FALSE (default) sorts rows top-to-bottom based on values in sort_index column. TRUE sorts columns left-to-right based on values in sort_index row. Rarely used — most data is sorted by rows.
5 real-world examples
Alphabetical customer list
Customer data in A2:D100. Sort ascending by column A (customer name).
All optional arguments defaulted — sorts by column 1, ascending, by rows. The simplest SORT.
Rank products by revenue descending
Same table with revenue in column 4. Sort by column 4, largest to smallest.
The -1 reverses the sort direction. Change the sort_index to sort by any column in the range.
Sorted view of filtered data
Get only West-region rows, sorted by revenue descending. FILTER first, SORT second.
The classic dashboard pattern. FILTER narrows the data, SORT reorders it. Both update dynamically.
Sort columns of monthly data by their totals
Monthly sales data with months as columns (Jan, Feb, Mar...) and products as rows. Sort columns from best-selling month to worst.
The TRUE for by_col tells SORT to reorder columns instead of rows. Uncommon but powerful for horizontal data layouts.
Top 10 salespeople by revenue
Combine SORT with TAKE to grab the top N rows.
SORT ranks everyone. TAKE picks the top 10. Perfect for a leaderboard widget in a dashboard.
Common errors and how to fix them
sort_index out of range
You wrote =SORT(A2:C100, 5, 1) — but the array only has 3 columns. Column 5 doesn't exist.
Invalid sort_order
You passed something other than 1 or -1 for sort_order, like 2 or 0. Only those two values are valid.
Cells needed for spill are blocked
SORT wants to spill into 99 rows below, but one is occupied. Excel refuses to overwrite.
Numbers and text sort separately
Excel sorts numbers before text when both are in the same column. Column with "10, 2, apple, banana" sorts as: 2, 10, apple, banana — numeric order for numbers, alphabetic for text.
See our Dynamic Array Errors guide for more.
SORT vs alternatives
Version compatibility
Related functions
📥 Download the practice workbook
All 5 examples with sample dashboard using SORT + FILTER + TAKE combos. Includes a leaderboard template.
Frequently asked questions
How do I do a multi-level sort with SORT?
SORT itself handles only one level. For multi-level sorting (by department, then by salary), use SORTBY: =SORTBY(range, dept_col, 1, salary_col, -1). Sort by dept ascending, then within each dept sort by salary descending.
Does SORT modify my original data?
No. SORT is non-destructive — it produces a sorted copy in a different location. The source range stays exactly as you left it. This is a big advantage over manual Sort which reorders in place.
How do I sort alphabetically ignoring case?
SORT is case-insensitive by default — "apple" and "APPLE" sort together. For case-sensitive sorting, you'd need to use SORTBY with a helper column applying EXACT() comparisons, or use Power Query.
Can SORT handle a column of dates?
Yes, as long as they're actual date values (not text that looks like dates). Ascending sorts chronologically oldest-to-newest; descending sorts newest-to-oldest. Test with =ISNUMBER() on your date cells to confirm they're real dates.
How do I reverse a range (flip upside down)?
Use SORT with SEQUENCE as a helper: =SORTBY(range, SEQUENCE(ROWS(range)), -1). Creates row numbers, then sorts descending — flipping the order without needing a sort key.
Is SORT slow on big data?
SORT is well-optimized for tens of thousands of rows. Past 100K rows, you may notice recalculation lag if it triggers frequently. For sorting huge datasets that only need to be done once, Power Query is more efficient.
Can I sort by multiple criteria — like Region then Revenue?
Use SORTBY, not SORT. Example: =SORTBY(data, region_col, 1, revenue_col, -1). First sorts by region ascending, then within each region sorts by revenue descending. SORT itself is single-level only.
Live-updating sorted dashboards.
Describe what you want — "top 10 sales reps by revenue with region filter" — and get the exact SORT/FILTER/TAKE combo ready to paste.
Get the Add-in →