Search code examples
arraysgoogle-sheetssplittransposeflatten

Sorting Multiple Columns in an Array


I have an array with 11 columns, containing only TRUE or FALSE values. I want to sort each column individually, such that all TRUE values are sorted to the top of each column.

This seems to work:

={{sort(index(indirect(B5),0,1),1,false)},{sort(index(indirect(B5),0,2),1,false)},{sort(index(indirect(B5),0,3),1,false)},{sort(index(indirect(B5),0,4),1,false)},{sort(index(indirect(B5),0,5),1,false)},{sort(index(indirect(B5),0,6),1,false)},{sort(index(indirect(B5),0,7),1,false)},{sort(index(indirect(B5),0,8),1,false)},{sort(index(indirect(B5),0,9),1,false)},{sort(index(indirect(B5),0,10),1,false)},{sort(index(indirect(B5),0,11),1,false)}}

but my desired output would only contain TRUE values, and not all the FALSE values as well.

Is there a good way to do this?


Solution

  • try:

    =INDEX(TRANSPOSE(SPLIT(FLATTEN(QUERY(IF(A1:C=TRUE, TRUE, ),,9^9)), " ")))
    

    enter image description here