SORTBY
Sorts a range or array by values in a corresponding range.
- Excel: Verified match
- Google Sheets: No equivalent
- Returns: Array
Examples
=SORTBY(A1:A5, B1:B5, -1) | A | B | |
|---|---|---|
| 1 | 10 | 2 |
| 2 | 20 | 4 |
| 3 | 30 | 6 |
| 4 | 40 | 8 |
| 5 | 50 | 10 |
Result 50
Syntax
SORTBY(array, by_array1, [sort_order1], [by_array2…], [sort_order2…]) array- range required
by_array1- range required
sort_order1- number optional defaults to
1 by_array2…- range optional
sort_order2…- number optional
Errors
#ERROR!=SORTBY(A2:A3,B2:B3,1,C2:C3)
Related
ARRAY_CONSTRAINTruncates a range to at most the given rows and columns. ARRAYFORMULAEvaluates an expression across a range (this engine already spills, so it is a pass-through for sheets compatibility). ARRAYTOTEXTConverts array to text representation. BYCOLApplies lambda to each column of array. BYROWApplies lambda to each row of array. CHOOSECOLSReturns the specified columns from an array.