Cellwise Try it free

Dynamic arrays function

Excel SORT function

SORT returns a sorted copy of a range, and it re-sorts by itself when the data changes. Use it for live leaderboards, low-stock lists, or any report where the source should stay in its original order.

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

Arguments

array
The range to sort.
sort_index
Optional. Which column of the range to sort by. Default is 1.
sort_order
Optional. 1 for ascending (default), -1 for descending.

SORT examples

Every result below was calculated from this sample sheet by the same spreadsheet engine the Cellwise app uses.

ABC
1ProductBinOn hand
2Desk fanB-0418
3Space heaterB-076
4Air purifierA-0211
5HumidifierA-093
6DehumidifierC-019
  1. =SORT(A2:A6)

    Result: spills 5 rows × 1 column

    Air purifier
    Dehumidifier
    Desk fan
    Humidifier
    Space heater

    Product names in A to Z order, starting with Air purifier.

  2. =SORT(A2:C6,3)

    Result: spills 5 rows × 3 columns

    HumidifierA-093
    Space heaterB-076
    DehumidifierC-019
    Air purifierA-0211
    Desk fanB-0418

    The whole table sorted by stock, lowest first. Humidifier tops the list.

  3. =SORT(A2:C6,3,-1)

    Result: spills 5 rows × 3 columns

    Desk fanB-0418
    Air purifierA-0211
    DehumidifierC-019
    Space heaterB-076
    HumidifierA-093

    Use -1 to sort descending: the best-stocked item comes first.

  4. =INDEX(SORT(C2:C6,1,-1),1)

    Result: 18

    Take the first row of a descending sort to get the top value.

How to use SORT

  1. Click the top-left cell of an empty area.
  2. Type =SORT( and select the data, without headers.
  3. Add the column number to sort by, and -1 for largest first.
  4. Press Enter. The sorted copy spills out.

Common SORT mistakes

Including the header row

The header gets sorted in with the data. Select from row 2 and type the headers above the formula.

Using a column letter for sort_index

sort_index is a number counted from the left of the range, not the sheet column.

Getting #SPILL!

Clear the cells where the sorted result needs to go.

SORT FAQ

How do I sort data automatically in Excel with a formula?

Use =SORT(A2:C20,2,-1). The result re-sorts whenever the source data changes.

How do I sort by multiple columns with SORT?

Pass arrays for both arguments, like =SORT(A2:C20,{2,3},{1,-1}), to sort by column 2 then column 3. Or use SORTBY.

Does the SORT function change my original data?

No. It returns a sorted copy somewhere else. The source stays exactly as it was.

Practice SORT in these lessons

Guides that use SORT

Related functions

Updated