I’ve blogged about how great sorttable is before. I use it a lot in work and people love it. However, because of the way sort-table works normally it won’t work with tables that are not in the document when the onload event for the document triggers. What does that mean in real terms? It means that if you use AJAX to render a table it won’t be sortable even if you include the sorttable.js file and set the class of the table to sortable. A quick scan of the source code showed me the answer, you have to manually call the function sorttable.makesortable() passing it the table you just got back from AJAX. The simplest way to do this is to give your table an ID and then use:

sorttable.makesortable(document.getElementById('the_table_id'));