I'd use CURSOR with ORDER BY in PL/SQL, loop over the rows and build up the output string by concatination (with break-point processing just as we did in the 70's).

If you really want the ouput in an Oracle table with a variable number of columns . . . .