Dynamic Arrays · Sorting without menus

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.

=SORT(array, [sort_index], [sort_order], [by_col])

Returns a sorted version of the input array. Sorts by any column, ascending or descending, dynamically. Never modifies the original data.

Category
Dynamic Arrays
Returns
Sorted array (spills)
Available since
Excel 365 (2020)

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

arrayRequired

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).

sort_indexOptional

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.

sort_orderOptional

1 ascending (default) — A to Z, small to large. -1 descending — Z to A, large to small. Any other value is an error.

by_colOptional

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

Example 1 · Sort by first column

Alphabetical customer list

Customer data in A2:D100. Sort ascending by column A (customer name).

=SORT(A2:D100)
Result: spills the sorted table below, alphabetized by column A

All optional arguments defaulted — sorts by column 1, ascending, by rows. The simplest SORT.

Example 2 · Sort by a different column

Rank products by revenue descending

Same table with revenue in column 4. Sort by column 4, largest to smallest.

=SORT(A2:D100, 4, -1)
Result: highest-revenue row on top, lowest at the bottom

The -1 reverses the sort direction. Change the sort_index to sort by any column in the range.

Example 3 · SORT + FILTER combination

Sorted view of filtered data

Get only West-region rows, sorted by revenue descending. FILTER first, SORT second.

=SORT(FILTER(A2:D100, A2:A100="West"), 4, -1)
Result: only West-region rows, sorted by revenue high-to-low

The classic dashboard pattern. FILTER narrows the data, SORT reorders it. Both update dynamically.

Example 4 · Sort horizontally

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.

=SORT(A2:M100, 20, -1, TRUE)
Result: columns rearranged so the highest-total month appears first

The TRUE for by_col tells SORT to reorder columns instead of rows. Uncommon but powerful for horizontal data layouts.

Example 5 · Top 10 leaderboard

Top 10 salespeople by revenue

Combine SORT with TAKE to grab the top N rows.

=TAKE(SORT(A2:B100, 2, -1), 10)
Result: top 10 rows by column 2 (revenue), descending

SORT ranks everyone. TAKE picks the top 10. Perfect for a leaderboard widget in a dashboard.

Common errors and how to fix them

#VALUE!

sort_index out of range

You wrote =SORT(A2:C100, 5, 1) — but the array only has 3 columns. Column 5 doesn't exist.

Fix: sort_index must be between 1 and the number of columns in the array (or rows if by_col is TRUE).
#VALUE!

Invalid sort_order

You passed something other than 1 or -1 for sort_order, like 2 or 0. Only those two values are valid.

Fix: use 1 for ascending, -1 for descending. No other values allowed.
#SPILL!

Cells needed for spill are blocked

SORT wants to spill into 99 rows below, but one is occupied. Excel refuses to overwrite.

Fix: clear the blocking cells, or move the formula to open space
Mixed types weirdness

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.

Fix: ensure consistent data types per column. Use =VALUE() to convert text-numbers to real numbers.

See our Dynamic Array Errors guide for more.

SORT vs alternatives

SORT Use when: you want a dynamic sorted view that updates as data changes. Dashboards, leaderboards, live reports. Excel 365 or 2021+.
SORTBY Use when: the sort key is in a different range than the output. Or when you need multi-level sorting (sort by A, then B, then C).
Manual Sort Use when: one-time reorganization of static data. Faster to click Sort than write a formula for a one-off. But changes to source data don't propagate.
Excel Table sort Use when: you want interactive sort headers users can click. Best for tabular data reviewed by humans. Semi-dynamic — persists but requires user action.
PivotTable sort Use when: sorting aggregated results (totals, averages) by their calculated values. PivotTables handle sort AND summary together.

Version compatibility

Excel 365
✓ Full support
Excel 2021
✓ Full support
Excel 2019
✗ Not available
Excel 2016
✗ Not available
Excel Online
✓ Full support
Excel Mac
✓ Full support
Excel iPad
✓ Full support
Google Sheets
✓ Full support

Related functions

📥 Download the practice workbook

All 5 examples with sample dashboard using SORT + FILTER + TAKE combos. Includes a leaderboard template.

Workbook coming soon — check back after our team releases it.

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 →