SORT

SORT(array [,sort_index] [,sort_order] [,by_col])

Returns the array of data in a range that has been sorted.

arrayThe range, or array to sort.
sort_index(Optional) The number indicating the row or column to sort by.
sort_order(Optional) The number indicating the desired sort order:
1 = for ascending order (default)
-1 = for descending order
by_col(Optional) A logical value indicating the desired sort direction:
False / 0 = to sort by row (default)
True / 1 = to sort by column

REMARKS
* This function was added in Excel 2021.
* This function is often used when you only want to sort by one column.
* This function can create a Dynamic Array Formula.
* If you want to sort by more than one column then you must supply array constants for the second and third arguments.
* If "sort_index" is left blank, then 1 (first column) is used.
* If "sort_index" is not numeric, then #NAME? is returned.
* If "sort_order" is left blank, then 1 (ascending) is used.
* If "by_col" is left blank, then False is used.
* You can use the FILTER function to filter and sort your data.
* You can use the SORTBY function to return an array of data that has been sorted.
* You can use the UNIQUE function to return an array of unique values from a list, table or cell range.
* For the Microsoft documentation refer to support.microsoft.com
* For the Google documentation refer to support.google.com

 ABC
1=SORT(B1:C4) = { "one", 30, "one", 50, "three", 10, "two", 20}one30
2=SORT(B1:C4,1,1) = { "one", 30, "one", 50, "three", 10, "two", 20}two20
3=SORT(B1:C4,1,-1) = { "two", 20, "three", 10, "one", 30, "one", 50, }one50
4=SORT(B1:C4,2,1) = { "three", 10, "two", 20, "one", 30, "one", 50}three10
5=SORT(B1:C4,2,-1) = { "one", 50, "one", 30, "two", 20, "three", 10}  
6=SORT(B1:C4,{1,2},{1,-1}) = { "one", 50, "one", 30, "three", 10, "two", 20}   
7=SORT(FILTER(B1:C4,C1:C4<25),2,1) = { "three", 10, "two", 20}  
8=SORT(B1:C4,"text") = #NAME?  

1 - Sort all the rows in the range "B1:C4" by column 1, in ascending order.
2 - Sort all the rows in the range "B1:C4" by column 1, in ascending order.
3 - Sort all the rows in the range "B1:C4" by column 1, in descending order.
4 - Sort all the rows in the range "B1:C4" by column 2, in ascending order.
5 - Sort all the rows in the range "B1:C4" by column 2, in descending order.
6 - Sort all the rows in the range "B1:C4" by column 1, ascending AND by column 2, descending.
7 - Show all the rows in the range "B1:C4", where column "C" has a value less than 25, sorted by column 2, in ascending order.
8 - If the "sort_index" is not numeric, then #NAME? is returned.

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