What SORTBY does
SORTBY sorts one range by using values from another range. That makes it useful when the values you want to display and the values you want to sort by are not in the same selected block.
Practical examples
Sort names by age
=SORTBY(D2:E9,E2:E9)
This returns the names and ages from D2:E9, sorted by the ages in E2:E9.
Sort by one helper column in descending order
=SORTBY(A2:C20,C2:C20,-1)
This keeps the original three-column output together while sorting by column C from highest to lowest.
Common mistakes and notes
SORTBY uses linked sort arrays
The by_array arguments must line up with the main array. If the shapes do not match, Excel cannot sort the result correctly.
Spill behavior still applies
Like other dynamic array functions, SORTBY needs room to spill the full result. Blocked cells can produce #SPILL!.
Use multiple sort keys when ties matter
If one sort key is not enough, add another by_array and sort_order pair instead of trying to nest extra sorting logic.