This function sorts the contents of a cell range or an array on the basis of the values present in a corresponding range or array.
Unlike the SORT function, the SORTBY function doesn't require the sort keys to be included inside the specified array or the sort range. However, it is necessary to allocate appropriate size to the sort keys (with respect to their correct length) while working with this function.
SORTBY(array, by_array1, [order_array1], [by_array2, order_array2], …)
SORTBY function has the following arguments:
Argument | Description |
---|---|
array | [required] Specifies the range or array that you want to sort. |
by_array1 | [required] Specifies the array or range of the first sort key. |
order_array1 | [optional] Specifies the sort order. The value 1 indicates ascending order and the value -1 indicates descending order. The default value is 1 i.e. ascending. |
by_array2 | [optional] Specifies the array or range of the second sort key. |
order_array2 | [optional] Specifies the sort order. The value 1 indicates ascending order and the value -1 indicates descending order. The default value is 1 i.e. ascending. This argument is required only if the by_array2 argument is specified. |
This function can accept additional arguments in pairs. Users can specify the next sort key range and order as per custom requirements.
Accepts a cell range or an array of data that you want to sort along with another cell range based on which the sort operation will take place. Returns a sorted array.
For instance - The cell G4 in the following image contains the formula "=SORTBY(A4:B15,B4:B15)". This function sorts the cell range A4 to B15 based on another cell range B4 to B15 and returns the customer names displayed along with their ages sorted in the increasing order (the default sort order).
This function is available in Spread for Windows Forms 12.1 or later.