Excel SORT Function

SORT returns a dynamically sorted copy of a range or array.

Use it to keep reports, leaderboards, task lists, unique lists, and filtered result sets ordered without manually sorting the source data.

1
Choose an array The source data to reorder
2
Choose sort settings Pick index, order, and direction
3
Spill sorted results The source range stays unchanged

SORT syntax & arguments

Syntax

=SORT(array, [sort_index], [sort_order], [by_col])
Required Optional
  1. 1

    array

    Required

    The range or array to sort.

  2. 2

    sort_index

    Optional

    The row or column number inside array to sort by. If omitted, SORT uses the first row or column.

  3. 3

    sort_order

    Optional

    Controls ascending or descending order:

    • 1 — Ascending: Sorts from smallest to largest or A to Z. This is the default.
    • -1 — Descending: Sorts from largest to smallest or Z to A.
  4. 4

    by_col

    Optional

    Controls the sort direction:

    • FALSE — Sort rows: Sorts rows by a column. This is the default.
    • TRUE — Sort columns: Sorts columns by a row.

Example

=SORT(A2:D20, 3, -1)

Sort rows in A2:D20 by the third column in descending order.

SORT caveats

SORT returns a sorted copy, so the output updates with the source but does not physically rearrange the original data.

  • The source data does not move

    SORT spills a separate sorted result while the original range remains in its existing order.

  • The sort index is positional

    sort_index is the row or column number inside array, not the worksheet column letter.

  • Sort direction changes by mode

    By default SORT sorts rows by a column. Set by_col to TRUE only when sorting columns by a row.

  • The result spills into nearby cells

    SORT returns a sorted copy with the same dimensions as array. If that output would cover multiple cells and any target cell is blocked, Excel returns a #SPILL! error.

Sorting a dynamic list? SORT pairs naturally with FILTER and UNIQUE when the source result changes over time.

Intro SORT practice problem

Solve the intro problem directly here, or open it on its own page.

Open full problem

Advanced SORT practice problems

Use SORT alongside other Excel functions in realistic, less-prescriptive challenges.