SORTBY(array, by_array1 [,sort_order1] [,by_array2] [,sort_order2])

Returns the array of data in a range that has been sorted based on the values in a corresponding range.

arrayThe array or range to sort.
by_array1The array or range to sort on.
sort_order1(Optional) The order to use for sorting:
1 = Ascending (default)
-1 = Descending
by_array2(Optional) The array or range to sort on.
sort_order2(Optional) The order to use for sorting:
1 = Ascending (default)
-1 = Descending.


* Only available in Microsoft 365 and was released in July 2020.
* This function can return a Dynamic Array Formula.
* If "array" and "by_array" are different sizes, then #VALUE! is returned.
* The "by_array" must be either a single column range or a single row range.
* If "sort_array" is not 1 or -1, then #VALUE! is returned.
* If there are not enough blank cells to display the full array, then #SPILL! is returned.
* You can use the SORT function to return an array of data that has been sorted.
* For the Microsoft documentation refer to

1=SORTBY("B1:B4","B1:B4") = { Mon, Thu, Tue, Wed }ThuJan
2=SORTBY("B1:B4","B1:B4",1) = { Mon, Thu, Tue, Wed }WedFeb
3=SORTBY("B1:B4","B1:B4",-1) = { Wed, Tue, Thu, Mon }MonMar
4=SORTBY("B1:B4","C1:C4") = { Tue, Wed, Thu, Mon }TueApr
5=SORTBY("B1:B4","A1") = #VALUE!  
6=SORTBY(B1:B4,C1:C4) = #SPILL!  

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top