Skip to content
ArumSoft Learning
KO

    Dynamic arrays

    SORT function playground

    Returns a sorted copy of a range.

    Available in: Excel 2021 and later, Microsoft 365Read the full tutorial →

    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])
    ArgumentWhat it means
    arrayrequiredThe range to sort.
    sort_indexoptionalWhich column of the range to sort by. Default 1.
    sort_orderoptional1 ascending (default), -1 descending.
    by_coloptionalFALSE (default) sorts rows; TRUE sorts columns.

    Examples

    FormulaWhat it doesResult
    =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.

    Learn more

    Download the example workbook (.xlsx)

    The workbook has the same sample data and formulas, plus a practice sheet.

    Read the full tutorial →