Note: This script is no longer updated/supported as it's replaced by much more advanced and the best of its kind TableTools script (listed under "publisher info" below) which sorts multi-column, searches (regex/range operations), filters (with selects), summarizes (avg, sum etc.) and copies HTML tables with the same setup effort as this one, which is merely to include script in html page header and add a class to your table.
Here's this old script's description - Include this script in your html page header and add class="sortable" to the tables you want sorted. Automatic detection and sorting of data types like currencies, US time/date, numbers (scientific notation too), IP addresses, etc; You can specify European styled date/time or other date format, or even specify custom data type thru custom sorting functions! Supports cookie (remember sort state), headers/footers, preserving the row/cell styles (eg alternatively highlighted rows), X-browser support etc.