Many thanks for posting the example. I presume that you have source data somewhere from which PIVOTBY calculates the outcome. Instead of using the row_fields range as you have it now (your current row_fields range), try to replace it with the following: REPT(UNICHAR(8203),XLOOKUP(your current row_fields range,your current custom order list,SEQUENCE(ROWS(your current custom order list),,ROWS(your current custom order list),-1)))&your current row_fields range. By "your current custom order list" I mean the list in the table 2 above. I.e. something like:
Excel Formula:
REPT(UNICHAR(8203),XLOOKUP(A2:A1000,E1:E10,SEQUENCE(ROWS(E1:E10),,ROWS(E1:E10),-1)))&A2:A1000