Sorting with SORT and SORTBY
Make a copy of the table sorted by name, A to Z, that updates by itself.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Name | Score | A to Z | |||
| 2 | Nadia | 66 | ||||
| 3 | Sam | 77 | ||||
| 4 | Kofi | 45 | ||||
| 5 | Felix | 62 | ||||
| 6 | Oscar | 70 | ||||
| 7 | Lena | 35 | ||||
| 8 | Quinn | 88 | ||||
| 9 | Victor | 98 | ||||
| 10 | ||||||
| 11 | ||||||
| 12 | ||||||
| 13 |
How SORT and SORTBY works
What does
SORTdo?It returns a sorted copy of a range that spills into the cells below and updates when the data changes. The original stays as it is.
=SORT(array,[sort_index], [sort_order]) What are the parts?
array: the rows to sort, without the headers.sort_index: which column of the array to sort by. 1 is the first, and the default.sort_order: 1 for smallest to largest or A to Z (the default), -1 for largest first or Z to A.
So
=SORT(A2:B9,2,-1)sorts by the second column, highest first.What does
SORTBYdo differently?SORTBYsorts by a separate range instead of a column number:=SORTBY(A2:B9,B2:B9,-1). The range to sort by doesn't have to be part of the result, and you can add more pairs to break ties:=SORTBY(A2:C9,B2:B9,1,C2:C9,-1)sorts by team, then by score within each team.How does it combine with other functions?
=SORT(FILTER(A2:C13,B2:B13="North"),3,-1)gives the North orders, biggest first.=SORT(UNIQUE(B2:B13))gives a sorted list without repeats.
Know someone fighting with a spreadsheet? Send them this page.