I have a range that I want to use TEXTJOIN on with delimiter CHAR(10) (linebreak) The values are the header names and the order is by the numbering that is on the row. If values are empty then ignore. see image below.
=TEXTJOIN(CHAR(10),TRUE,SORTBY(FILTER($A$1:$D$1,A2:D2),FILTER(A2:D2,A2:D2),1))
This would go in E2 and then you can drag the formula down. It filters the fruit names according to if there are rank numbers for them in that row, and removes any that don't (e.g. Orange and Peach on row 4). It then sorts by ascending number and joins the results with a line break.