SORT Function in Excel, Google Sheets, Airtable & Notion
SORT returns a sorted copy of a range and spills it, leaving the original data untouched. You choose the column to sort by and the direction; the result updates when the data changes.
Syntax in each app
| App | Support | Syntax & notes |
|---|---|---|
| Excel | ✔ Built in | SORT(array, [sort_index], [sort_order], [by_col])Excel 2021 / Microsoft 365 sort_order is 1 (ascending) or −1 (descending). SORTBY(array, by_array, [order]) sorts by a column outside the array. |
| Google Sheets | ✔ Built in | SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])Different from Excel: direction is TRUE/FALSE, and you can add more column/direction pairs. |
| Airtable | ✘ Not available | — Formulas cannot sort records. Sort a view instead; linked record, lookup and rollup fields keep the order the records were linked in. |
| Notion | ≈ Workaround | list.sort()Sorts a single list in ascending order, e.g. prop("Scores").sort(). It sorts values, not whole rows; to sort pages, sort the database view. |
| Excel | =SORT(A2:B6, 2, -1) | open excel.new ↗ |
|---|---|---|
| Google Sheets | =SORT(A2:B6, 2, FALSE) | open sheets.new ↗ |
| Airtable | ✘ No equivalent. Formulas cannot sort records. Sort a view instead; linked record, lookup and rollup fields keep the order the records were linked in. | |
| Notion workaround | [92, 75, 88, 64, 81].sort() | |
Excel & Sheets use cell ranges. Paste this sample data into cell A1 of a blank sheet, then paste the formula into any empty cell.
Name Score Ann 92 Ben 75 Cara 88 Dev 64 Eli 81
Notion's formula sorts only the chosen column, and always ascending.
Arguments
| Argument | What it means |
|---|---|
array | The range to sort, e.g. A2:B6. |
[sort_index] optional | Which column of the range to sort by (1 = first). Default 1. |
[sort_order] optional | Excel: 1 ascending (default) or −1 descending. Google Sheets: TRUE ascending or FALSE descending. |
[by_col] optional | Excel only: TRUE sorts columns instead of rows. |
Examples
| Formula | Result | Why | Copy |
|---|---|---|---|
=SORT(A2:B6, 2, -1) | Ann | 92, Cara | 88, Eli | 81, Ben | 75, Dev | 64 | Tester data: a leaderboard, highest score first. | |
=SORT(A2:B6, 2, FALSE) | Same as above | The Google Sheets way to write descending. | |
=SORT(A2:A6) | Ann, Ben, Cara, Dev, Eli | One column, A to Z. | |
=SORTBY(A2:A6, B2:B6, -1) | Ann, Cara, Eli, Ben, Dev | Excel only: names ordered by a column that is not returned. |
Examples use Excel / Google Sheets syntax unless noted.
How SORT works
SORT gives you a sorted copy of your data that stays live: change a score and the leaderboard re-orders itself, without touching the source range. That makes it ideal for dashboards, top-N lists (=TAKE(SORT(A2:B100, 2, -1), 5) in Excel 365) and sorted drop-down sources. The result spills, so leave room below and to the right or you get #SPILL!.
The arguments differ between apps, which is a common copy-paste bug. Excel uses a column number and 1 / -1 for the direction; Google Sheets uses a column number and TRUE / FALSE, and lets you add more column-direction pairs for tie-breaks. In Excel, sort on several columns with array constants, SORT(A2:C20, {2,1}, {-1,1}), or use SORTBY. Text sorts without regard to case, numbers come before text, and blank cells go to the end (and show as 0 in the result).
SORT needs Excel 2021 or Microsoft 365. Airtable cannot sort with a formula; sort the view instead. Notion's .sort() sorts the values of a list in ascending order, which is enough for a list of numbers or names but cannot re-order whole rows.
Frequently Asked Questions
- How do I sort in descending order?
- Excel:
=SORT(A2:B20, 2, -1). Google Sheets:=SORT(A2:B20, 2, FALSE). - How do I get the top 3?
- Excel 365:
=TAKE(SORT(A2:B20, 2, -1), 3). Google Sheets:=ARRAY_CONSTRAIN(SORT(A2:B20, 2, FALSE), 3, 2). For just the values, LARGE works everywhere.