SORT Function in Excel: Sort Data With a Formula

SORT Function in Excel: Sort Data With a Formula featured illustration

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 12 October 2026

Dynamic ArrayLevel: ExpertAvailable in: Excel 365 / 2021+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. Example 2
  5. Power combo
  6. SORT in practice
  7. Where you will use it
  8. Worked example
  9. Mistakes people make
  10. Related functions
  11. Continue learning

SORT returns a sorted copy of a range; the original stays untouched and the result re-sorts as data changes.

Advertisement

Syntax

=SORT(array, [sort_index], [sort_order], [by_col])
Argument What it means
sort_index Which column to sort by (1 = first).
sort_order 1 ascending, βˆ’1 descending.

Examples

Example 1

=SORT(A2:E500, 5, -1)

By amount, largest first.

Example 2

=SORT(A2:E500, {2,5}, {1,-1})

By region A–Z, then amount high–low.

Power combo

=TAKE(SORT(A2:E500, 5, -1), 10)

Top 10 rows (TAKE needs the 2022 update).

SORT in practice

Where you will use it

  • Live sorted lists
  • Top sellers by value
  • Sorted dropdown sources

Worked example

OrderFormulaResult
1=TEXTJOIN(", ",,SORT({"Pune";"Agra";"Delhi"},1,A2))Agra, Delhi, Pune
-1=TEXTJOIN(", ",,SORT({"Pune";"Agra";"Delhi"},1,A3))Pune, Delhi, Agra
1=TEXTJOIN(", ",,SORT({"Pune";"Agra";"Delhi"},1,A4))Agra, Delhi, Pune

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Sorting by another columnUse SORTBY
Spill blockedClear space

SORTBY Β· FILTER Β· UNIQUE Β· TAKE

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Dynamic arrays18 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 35 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *