I wrote this post a while back. The content can still be relevant but the information I've linked to may not be available.
I know we are not building websites using tables for layout any more (ahem) but tables are still the best way of displaying related data. The table often pulls information from a database using an SQL query that orders the data according to one of the column data headers. For example, display some data and sort it alphabetically or perhaps in date order, either descending or ascending.
Here's a great table sorting script by Stuart Langridge that gives your website users1 the ability to click on each column header to sort the data themselves. Implementation is easy, download the script, reference it in the head of your document, add a class name to your table, and that's it. Table sorting made easy....
I have used this to make the admin section of one of my own websites much easier to manage. The table sorting script provides alternative table views without resorting to additional database calls. Cool.