Mysql output to csv putting column names on the bottom
The records order is defined by your ORDER BY clause expression. All id field values are converted to string type due to the type of the base (first) subquery field type. Of course the digits are first and letters last. 

Replace it with 

ORDER BY id='id' DESC, id