Spreadsheet Practice

How to sort a list by another column in Excel

Excel formula

=SORTBY(A2:A9,C2:C9,-1)

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.

Result on the example
a 8-row list that spills from E2 in E2
Works in
Excel 2021, 2024 and Microsoft 365
Google Sheets
Different formula, see below

See it work

The formula is already in E2. Change any input and the result updates, or edit the formula to experiment.

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.

=SORTBY(A2:A9,C2:C9,-1)

Result{8 rows × 1 col} "Webcam", "Desk lamp", "Laptop stand", "Monitor arm", …

  1. A2:A98 rows × 1 col: "Desk lamp", "Office chair", "Standing desk", "Monitor arm", …

    A range: 8 cells in one column.

  2. C2:C98 rows × 1 col: 312, 148, 96, 225, …

    A range: 8 cells in one column.

  3. -1-1

    Makes the value negative.

  4. SORTBY(A2:A9,C2:C9,-1){8 rows × 1 col} "Webcam", "Desk lamp", "Laptop stand", "Monitor arm", …

    SORTBY: Sorts a range by other ranges. Spills.

    • arrayA2:A98 rows × 1 col: "Desk lamp", "Office chair", "Standing desk", "Monitor arm", …
    • by_array1C2:C98 rows × 1 col: 312, 148, 96, 225, …
    • sort_order1-1-1

In Google Sheets

Google Sheets needs a different formula: =SORT(A2:A9,C2:C9,FALSE). On the same data it gives the same result. Here it is running in Google Sheets mode.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=CHOOSECOLS(SORT(A2:C9,3,-1),1)Excel onlyspills 8 × 1Sort the whole table by its third column, then keep the first column.
=SORTBY(A2:A9,C2:C9,1)Excel onlyspills 8 × 1Different resultUse 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).

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Sort a list by another column

In E2, list the product names from A2:A9, ordered by units sold in column C from highest to lowest. Return the names only.

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).

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.