Explaining is always the hardest part....
The idea is to assign a value to every row, including the spaces in between teams, so that way we can sort by that row since you only have those total scores in one row for each group of 4 rows.
Ok, let's go from inside out...
This - ISNUMBER($O8:$O$107) checks if there are numbers in that range... notice I do not have a $ before the 8 in the first part of the range... so as you copy down the formula is checking from the row you are in downwards...
The INDEX() around that is used because the MATCH() formula here is an array formula, and using the INDEX() gives an array of results without having to confirm it with CTRL+SHIFT+ENTER as is usual for Array formulas.
The MATCH(TRUE,INDEX(ISNUMBER($O8:$O$107),0),0) now checks for the first time the ISNUMBER() gives a TRUE result (as we are going down the column). It returns the position from the row you are in that the match is found, then that position is the "row" value for the INDEX() function in INDEX($O8:$O$107,MATCH(TRUE,INDEX(ISNUMBER($O8:$O$107),0),0)) so that the value returned is the value that was matched.
The IFERROR() allows me to return a large number 999 if there are no more matches (which would return an error) and those would be at the bottom where you have no more scores.
I think maybe you don't even need the AND($C8="",$C9="") part at the beginning and could get away with just: =IFERROR(INDEX($O8:$O$107,MATCH(TRUE,INDEX(ISNUMBER($O8:$O$107),0),0)),999)
It was a remnant of my testing out possibilities...