It would've been better if you had posted your current search generating those output. Assuming that your last command was something on the lines of
..| stats list(Code) as Code list(Pool) as Pool by Name OR
..| stats values(Code) as Code values(Pool) as Pool by Name, give this a try..
your current search before the last stats | sort 0 Name -Code | stats list(Code) as Code list(Pool) as Pool by Name
|makeresults | eval raw="Name1 100 p1 Name1 57 p32 Name1 63 p43 Name1 230 p27 Name2 120 p2 Name2 77 p33 Name2 83 p44 Name2 250 p28" | makemv delim=" " raw | mvexpand raw | rename raw AS _raw | rex "^(?<Name>\S+)\s+(?<Code>\S+)\s+(?<Pool>\S+)$" | stats count BY Name Code Pool | stats list(*) AS * BY Name | rename COMMENT AS "Everything above generates sample event data; everything below is your solution" | eval Combo=mvzip(Code, Pool) | fields Name Combo | mvexpand Combo | rex field=Combo "^(?<Code>[^,]+),(?<Pool>.*)$" | sort 0 - Code | fields - Combo | stats list(*) AS * BY Name