0Pricing
Excel Formulas Academy · Lesson

Sorting by Another Column With SORTBY

Order one array using the values from a different array.

Why SORTBY Exists

SORT orders data by a column that is inside the array. But what if you want to order one list by the values in a separate array that is not part of the output?

That is exactly what SORTBY does. It sorts one range using the order of completely different ranges, giving you flexible, multi-key sorting without including the sort columns in your results.

=SORTBY(A2:A10, B2:B10)

The SORTBY Syntax

SORTBY's pattern is:

  • array the data you want returned, in sorted order
  • by_array1 the values that decide the order
  • sort_order1 1 for ascending, -1 for descending (optional)

You can keep adding by_array / order pairs to sort by several keys. Each by_array must be the same height (or width) as the array being sorted.

=SORTBY(array, by_array1, [order1], [by_array2], [order2], ...)

All lessons in this course

  1. Ordering Results With SORT
  2. Sorting by Another Column With SORTBY
  3. Generating Numbers With SEQUENCE
  4. Creating Random Data With RANDARRAY
← Back to Excel Formulas Academy