# How to sort a list by another column in Excel

Use SORTBY with the other column as the key: `=SORTBY(A2:A9,C2:C9,-1)` returns the product names ordered by units sold, highest first.

**Excel:** `=SORTBY(A2:A9,C2:C9,-1)` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** `=SORT(A2:A9,C2:C9,FALSE)`

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Product | Category | Units sold |  | Best sellers |
| Desk lamp | Lighting | 312 |  |  |
| Office chair | Seating | 148 |  |  |
| Standing desk | Furniture | 96 |  |  |
| Monitor arm | Accessories | 225 |  |  |
| Webcam | Electronics | 410 |  |  |
| Desk mat | Accessories | 187 |  |  |
| Laptop stand | Accessories | 264 |  |  |
| Floor lamp | Lighting | 73 |  |  |

Formula in E2: `=SORTBY(A2:A9,C2:C9,-1)`

Result (spills 8 × 1): Webcam; Desk lamp; Laptop stand; Monitor arm; Desk mat; Office chair; Standing desk; Floor lamp

## How it works

SORTBY sorts one range by the values in another range of the same height. The units in `C2:C9` decide the order, `-1` makes it highest first, and only the names come back. In Google Sheets, SORT accepts a range as its sort column, so it does the same job.

## Other ways

- `=CHOOSECOLS(SORT(A2:C9,3,-1),1)`: Sort the whole table by its third column, then keep the first column.
- `=SORTBY(A2:A9,C2:C9,1)`: Use 1 for lowest first. (Floor lamp first, Webcam last.)

## Common mistakes

- The key range must be exactly as tall as the list: `A2:A9` with `C2:C9`. A different size returns #VALUE!.
- SORTBY is Excel only. In Google Sheets write `SORT(A2:A9,C2:C9,FALSE)`.

## Questions

**Can the sort key be a calculation?**

Yes. `=SORTBY(A2:A9,LEN(A2:A9))` sorts names from shortest to longest.

**How do I show the units next to the names?**

Sort both columns: `=SORTBY(HSTACK(A2:A9,C2:C9),C2:C9,-1)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/sort-a-list-by-another-column
