Quick Navigation
SORT Function
Summary
The SORT function dynamically sorts the contents of a range or array, returning a spilled array in the same shape as the input. Perfect for creating live-updating sorted lists without manual sorting.
Syntax
SORT(array,[sort_index],[sort_order],[by_col])
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | Range/Array |
Yes | Range or array containing the data to sort |
| sort_index | Number |
No | Position (1-based) of row/column to sort by. Defaults to 1. |
| sort_order | Number |
No | Sort direction: 1=ascending (default), -1=descending |
| by_col | Boolean |
No | TRUE=sorted by columns, FALSE=default (by rows) |
Using the SORT Function
SORT creates dynamic, automatically updating sorted arrays that spill into adjacent cells. Ideal for dashboards and reports where data sorting needs to update live as source data changes.
Common SORT Examples
Basic Ascending Sort
=SORT(A2:A20)
Sorts entire column A in ascending order using first column as key.
Descending Sales Sort
=SORT(A2:C20,2,-1)
Sorts sales data by column 2 (Sales) in descending order.
Sort by Rows Horizontally
=SORT(A1:E1,,1,TRUE)
Sorts single row left-to-right by first row.
Combined with FILTER
=SORT(FILTER(A2:D20,D2:D20>5000),4)
Sort filtered sales data (over $5000) by Date column.
Frequently Asked Questions
Common Errors and Solutions
#SPILL!
Cause: Cells in spill range contain data
Solution: Clear cells where sorted array should appear
#VALUE!
Cause: Invalid sort_index or sort_order values
Solution: sort_index must be positive integer, sort_order 1 or -1
#REF!
Cause: Source workbook closed for cross-workbook arrays
Solution: Keep both workbooks open
Notes
- Available only in Excel 365 and Excel 2021+
- Uses 1-based indexing for sort_index
- Spilled arrays auto-resize with Excel Tables
- SORTBY preferred for grid-based sorting with changing columns
Compatibility
Available in: Excel 365, Excel 2021
Not available in: Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2007
Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 365, Excel 2021