Dynamic arrays
SORT function playground
Returns a sorted copy of a range.
The playground runs in your browser. Nothing you type is sent anywhere.
How SORT works
SORT returns a new, sorted list that spills; the original data doesn't move. sort_index counts columns inside the range, so in C2:F11 the Revenue column is 4.
Wrap other dynamic array functions in SORT, such as =SORT(UNIQUE(D2:D11)).
Syntax
=SORT(array, [sort_index], [sort_order], [by_col])| Argument | What it means |
|---|---|
arrayrequired | The range to sort. |
sort_indexoptional | Which column of the range to sort by. Default 1. |
sort_orderoptional | 1 ascending (default), -1 descending. |
by_coloptional | FALSE (default) sorts rows; TRUE sorts columns. |
Examples
| Formula | What it does | Result |
|---|---|---|
=SORT(C2:F11,4,-1) | Rep, product, units and revenue, largest revenue first. | Dev (spills 10×4) |
=SORT(C2:C11) | Rep names A to Z (duplicates stay). | Ana (spills 10×1) |
=SORT(UNIQUE(D2:D11)) | A sorted list of products. | Laptop (spills 3×1) |
=SORT(A2:F11,5,-1) | All columns, sorted by units, most first. | 2/20/2026 (spills 10×6) |
Common mistakes
Wrong sort_indexCount columns from the left of the array, not from column A.
#SPILL!Leave room below and to the right for the result.
Related functions
Learn more
Download the example workbook (.xlsx)
The workbook has the same sample data and formulas, plus a practice sheet.