The SORT function

Sorts the rows of a range by one of its columns and spills the sorted copy into the cells below. The original data stays as it is.

Syntax

SORT(array, [sort_index], [sort_order], [by_col])
array
The range to sort.
sort_index (optional)
Which column of the range to sort by, counted from 1. Left out, the first column.
sort_order (optional)
1 or left out for smallest to largest (A to Z), -1 for largest to smallest.
by_col (optional)
TRUE to sort the columns of the range instead of its rows.

Examples

D1=SORT(A2:B5)
ABCDE
1NameSalesAva275
2Maya320Ben450
3Ben450Maya320
4Zoe180Zoe180
5Ava275
D1=SORT(A2:B5,2,-1)
ABCDE
1NameSalesBen450
2Maya320Maya320
3Ben450Ava275
4Zoe180Zoe180
5Ava275

In plain words: Sort the names and sales in A2:B5 by the second column, largest first.

D1=SORT(B2:B5)
ABCD
1NameSales180
2Maya320275
3Ben450320
4Zoe180450
5Ava275

Practice SORT

Read the guide

Questions

Why does SORT return

The sorted result needs empty cells to spill into, and something is in the way. Clear the cells below and to the right of the formula.

Does SORT work the same way in Google Sheets?

Google Sheets has SORT too, but its arguments differ. You give the column to sort by and TRUE or FALSE for ascending, as in =SORT(A2:B5,2,FALSE), and you can add more column and order pairs.

Related functions