I assume you're putting the parameters into a server-side generated <table> element.
As you read each row of data from your query return, map it to an array element directly:
For example, if your have row element A, B, and C, and you wish to output them in the order B, C, A, then do the following:
if your sort order is in the array $order = (2,3,1);
$row = Get_The_Row_From_SQL_Return();
for($j=0; $j $td[$order[$j]] = $row[j];
Now, use then array $td to create your table row:
$rowText = '<table><tbody><tr>';
foreach($td as $t)
$rowText .= "<td>$t</td>";
$rowText .= '';
</tr></tbody></table>
You have now generated a table with data element position remapped.