SORT Function
The Excel SORT function returns a dynamic sorted copy of a range or array without rearranging the source data.
| Excel SORT Function | |||||||||||
| SORT returns an automatically updating sorted copy without changing the source range. | |||||||||||
| Source data, editable | Dynamic sorted views | ||||||||||
| Name | Region | Amount | Example | Formula syntax | Name | Region | Amount | ||||
| Jordan | East | $95 | Amount ascending | =SORT(A12:C17,3,1) | Riley | East | $80 | ||||
| Avery | North | $120 | Jordan | East | $95 | ||||||
| Morgan | South | $180 | Devon | South | $105 | ||||||
| Casey | North | $150 | Avery | North | $120 | ||||||
| Riley | East | $80 | Casey | North | $150 | ||||||
| Devon | South | $105 | Morgan | South | $180 | ||||||
| Names A–Z | =SORT(A12:A17) | Avery | |||||||||
| Casey | |||||||||||
| Devon | |||||||||||
| Jordan | |||||||||||
| Morgan | |||||||||||
| Riley | |||||||||||
| Reliability checks | |||||||||||
| Ascending amount view starts with Riley at 80 | OK | ||||||||||
| The source first row remains Jordan | OK | ||||||||||
Overview
The Excel SORT function returns the contents of a range or array in ascending or descending order. The sorted result spills into a new location and updates automatically; it does not rearrange the source range in place.
Quick reference
Syntax: =SORT(array, [sort_index], [sort_order], [by_col])
Returns: A dynamic array containing the source values in the requested order. (array)
Arguments:
array(required) — The range or array to sort.sort_index(optional) — The one-based column position, or row position when sorting by columns; default is 1.sort_order(optional) — 1 for ascending or -1 for descending; default is ascending.by_col(optional) — FALSE sorts rows and TRUE sorts columns; default is FALSE.
Only the source array is required. Optional arguments select the sort position, direction, and orientation; their defaults sort rows by the first column in ascending order.
Common uses
- Build an alphabetic list that updates with source changes.
- Rank records by a numeric value.
- Sort dates chronologically or reverse-chronologically.
- Order a FILTER or UNIQUE result.
Calculations
SORT reads array, orders its rows by the selected column position, and spills the reordered values into a new result range. When optional arguments are omitted, it sorts rows by the first column in ascending order.
sort_index is relative to array. If the supplied array is F:J, an index of 3 means its third column, not worksheet column C. Setting sort_order to -1 reverses the order.
Because the result is a dynamic array, the spill area must remain empty. Changes to source values recalculate the sorted view while preserving the original source order.
Function behavior
Situation | Behavior |
|---|---|
Optional arguments omitted | Sorts rows by the first column ascending. |
| Refers to position inside |
| Sorts ascending. |
| Sorts descending. |
| Sorts rows; this is the default. |
Source changes | Recalculates the spilled sorted view. |
Occupied spill range | Returns |
Common errors
Expecting an in-place sort
What happens:
The source table remains in its original order.
Better approach:
Use SORT when a separate live view is desired; use Excel's Sort command when the source itself must be rearranged.
Using the worksheet column number
What happens:
The wrong sort position or an invalid index is supplied.
Better approach:
Count columns from the left edge of array.
Blocking the result area
What happens:
The formula returns #SPILL!.
Better approach:
Keep the full dynamic result area empty.
Example
Example 1 — Sort a Table by Amount
=SORT(A12:C17,3,1)
The workbook sorts the three-column table by its third column in ascending order. Riley at $80 appears first and Morgan at $180 appears last.
Example 2 — Sort a One-Column Range
=SORT(A12:A17)
With defaults applied, the names spill alphabetically: Avery, Casey, Devon, Jordan, Morgan, and Riley.
Example 3 — Descending Order
=SORT(A12:C17,3,-1)
Changing the order argument to -1 would place Morgan's $180 amount first.
Example workbook
The workbook contains SORT Example and Notes. The main sheet provides an editable six-row table, a live amount-ascending SORT result, and a live alphabetic name result. IF and AND checks confirm the first sorted record and the unchanged source order; both display OK.
Key takeaway
SORT creates a live ordered view; choose the sort column by its position inside the supplied array and leave the spill range empty.