SOLVED: How to Sort a Table on an HTML Page

I thought this was going to be a royal pain but it turned out to be VERY simple thanks to a small, free, simple little tool.

If you have a table on your website and you want to let visitors sort the data in it by just clicking a column heading, follow these steps:

  1. Download the Javascript library
  2. Include the Javascript library, by  putting a link to it in the HEAD of your page, like so:
    <script src="sorttable.js"></script>
  3. Mark your table as a sortable one by giving it a class of “sortable”:
    <table class="sortable">

    Note that the library’s JavaScript file is called    sorttable (two Ts), but the class you add to the table is    sortable (one T).

This little jscript and two VERY simple changes to your code is all it takes.  It took me longer to read the instructions than it did to follow them.

This was taken directly from … and thank you to Suart Langridge for his fine coding efforts.


Questions or Comments?