Sort a table by sales with SORT
In D2, return the table A2:B6 sorted by sales, highest first. SORT takes the range, the column to sort by (2) and the order (-1 for descending).
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Rep | Sales | Rep | Sales | ||
| 2 | Ann | 420 | ||||
| 3 | Ben | 310 | ||||
| 4 | Cy | 150 | ||||
| 5 | Di | 500 | ||||
| 6 | Ed | 260 | ||||
| 7 | ||||||
| 8 |
Need help?
Why this works
The second argument counts columns inside the range, so 2 is Sales. -1 sorts from highest to lowest (1, the default, goes from lowest to highest). The result spills into D2:E6 with each name still next to its own sales, and it re-sorts when the data changes.
Common mistake: Sorting only the sales column. The numbers come out in order, but the names no longer sit next to them.
The answer
- D2
=SORT(1A2:B6,22,3-1)
In plain words: Sort 1the table in A2:B6 by 2its second column, the sales, 3highest first.
=SORT(A2:B6,2,-1) returns A2:B6 sorted by its second column in descending order. Use 1 or leave out the last argument for ascending.
Almost. In Google Sheets the third argument is TRUE for ascending or FALSE for descending, so the same sort is =SORT(A2:B6,2,FALSE).
+15 points