SORTBY Function
Return the values of an array sorted by the values of another array. by_array1 holds the sort keys and must have as many rows (or columns) as array, and sort_order1 is 1 for ascending or -1 for descending; further pairs of by_array and sort_order break ties. The sorted array spills into the neighboring cells. In TX Sheet Control, sort_order1 is required: without it, or with a key array of another size, SORTBY returns #VALUE!.
Syntax
SORTBY(array, by_array1, sort_order1)
Category: Lookup. Minimum arguments: 3. Maximum arguments: 255.
Available for supported offline calculation.
Examples
=SORTBY({"a";"b";"c"},{3;1;2},1)
The formula spills b, c and a: the keys 1, 2 and 3 put the values in that order.
Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.