==SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2],…)
=SORTBY(A1:A5,B1:B5,1)
For example, this sorts the values in A1:A5 according to the values in B1:B5 in ascending order.
=SORTBY(A1:A5,{3;5;2;1;4})
The SORTBY function can also be used with an array constant. An array constant is an array of values specified directly in the formula. Array constants are enclosed in curly braces {} with each array element separated by a semicolon ;.For example, the function sorts the values in A1:A5 using the array constant 3, 5, 2, 1, and 4.
=SORTBY(A1:A5,B1:B5,C1:C5,1)
The SORTBY function can also be used to sort data based on multiple criteria. This can be done by providing multiple ranges in the range2 argument of the function. For example, this formula sorts the values in A1:A5 according to the values in B1:B5 and C1:C5 in ascending order.
The SORTBY function allows users to sort a range or array according to the values in a corresponding range or array. It returns an array and requires by_array arguments that must be one row or one column wide and of the same size as the sort_order arguments. The array must be sorted in ascending order.