SORTBY
Description
Sorts the specified array or range based on the values in a corresponding array. You
can specify pairs of by_array and sort_order arguments for a primary sort, secondary
sort, and so on. This function is intended for use with unconstrained arrays. To
submit the formula, use the unconstrained keyboard shortcut Ctrl+Alt+Enter (on
Windows) or Command+Option+Enter (on Mac).
Syntax
SORTBY(
array
,
by_array1
, [
sort_order1
], [
by_array2
,
sort_order2
], ...)
- array: The array to sort.
- by_array1: The array to sort on.
- sort_order1: A number that specifies the sort order. Specify 1 to sort in ascending order or -1 to sort in descending order. The default is 1 (ascending).
- by_array2: A second priority array to sort on.
- sort_order2: A number that specifies the sort order for the secondary sort. Specify 1 to sort in ascending order or -1 to sort in descending order. The default is 1 (ascending).
Related Functions
ARRAYAREA
SORT
SORT2