Sorting with SORT and SORTBY

1 / 4

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.

A1
ABCDEF
1NameScoreA to Z
2Nadia66
3Sam77
4Kofi45
5Felix62
6Oscar70
7Lena35
8Quinn88
9Victor98
10
11
12
13
scores
sorted copy
Type to enter a value or a formula starting with =. F2 edits, F4 adds $ to a reference.
Study notes

How SORT and SORTBY works

  • What does SORT do?

    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 SORTBY do differently?

    SORTBY sorts 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.