Assuming your dataset is paginated, the simplest was is to make the column headings links that add a parameter to that determines the sort order when you pull the result from the database.
eg.
Code:
<a href="?column=name&order=asc">Name</a><a href="?column=email&order=asc">Email</a>
This can easily be extended by doing things such as:
- making the links dynamic, allowing asc or desc ordering.
- adding html/css to highlight the sorted row (eg. an arrow)
- storing the order in a session/cookie so it is persisted if the user returns to the page
- performing the lookup via JavaScript (Ajax) to avoid a page load.
Depends what you want to achieve.