You have to add the ordering clause to your final query. When you save the data into a table (in this case table #A and subsequently table #B), the data is stored with no consideration to ordering. Data in a SQL table is an unordered collection. The ONLY way to guarantee ordering in the output is to add the order by clause into your final select.
select name+'|'+age+'|'+gender+'|'+status [output],ordering
select output from #B order by ordering;