Something like this would work great (there may be better ones still): https://www.datatables.net/examples/styling/bootstrap4.html
You could have:
<th>
<a href="/search?sort=name&direction=asc"> Name <a>
The server side code would interpret the sort and direction parameters and sort results as instructed.
Something like this would work great (there may be better ones still): https://www.datatables.net/examples/styling/bootstrap4.html