It's tedious but can be accomplished with server side sorting.
You could have:
<th>
<a href="/search?sort=name&direction=asc">
Name
<a>
</th>The server side code would interpret the sort and direction parameters and sort results as instructed.