Excel Function

SORTBY

Sorts array by another array.

SORTBY(array, by_array1, [sort_order1], ...)

Arguments

array

Required

Specify a reference range. You can drag or click start/end cells.

by_array1

Required

Specify a reference range. You can drag or click start/end cells.

sort_order1

Optional

Enter a numeric value.

Practice Preview

Use SORTBY to return the result with these settings (Target range: A2:D8 (columns A to D), Sort key range: D2:D8 (Sales in column D), Sort order: -1 (descending)). You can set ranges by dragging from the start cell to the end cell in the same argument field.

Example Table

#
AProduct ID
BCategory
CProduct Name
DSales
2P001FoodApple1200
3P002FoodBanana980
4P003StationeryNotebook450
5P004StationeryPen300
6P005FoodGrapes1500
7P006StationeryRuler250
8

How to Use (Formula)

=SORTBY(A2:D8, D2:D8, -1)

Result

P005, Food, Grapes, 1500 | P001, Food, Apple, 1200 | P002, Food, Banana, 980 | P003, Stationery, Notebook, 450 | P004, Stationery, Pen, 300 | P006, Stationery, Ruler, 250 | , , ,

Practice This Function

SORTBY FAQ

How do I use SORTBY in Excel?

Use SORTBY when you want to sort data by another column. Enter Target range, Sort key range, Sort order in that order, then add optional arguments when needed.

Where can I practice SORTBY?

Use the "Start Function Practice" button to jump straight into SORTBY drills.

What arguments does SORTBY use?

The main arguments are Target range, Sort key range, Sort order. Start with the required ones, then add optional arguments if needed.