I have a spreadsheet with lots of related rows. How can I sort the entire sheet in such a way that rows that belong together stay together in groups, and the groups instead are sorted by some common property?
For example, this sheet with 6 groups and 2 columns
set1 element1 1
set1 element2 33
set1 element3 ?
set1 element4 5
set2 element5 1
set3 element6 6
set4 element7 14
set4 element8 14
set5 element9 3
set6 element10 1
set6 element11 8
set6 element12 13
Some criteria I'd like to sort by:
- Order groups so ones that have at least one '?' in column C are on top,
- Order groups by the minimum/maximum/average/etc value of all cells in column C of the group that are not '?'
The relative order of rows inside of groups should not be changed.
I realize this will require some scripting, but I've only done 1-line scripts before and even those were found here, so I can't do this by myself. With regards to the processing time, the sheet is about 11270x20 cells and two columns are filled with formulas like the following:
=if(isdate(F4),if(F4="?","?",(year($F4)-2000)*4+floor(($F4-date(year($F4),3,1)+if(month($F4)<3,60,59)+13.3)/91.8,1)),"…")
=if(and(E3="",H3=""),"…",if(isnumber(H3*E3),H3*E3,"?"))