SortTable

https://www.kryogenix.org/code/browser/sorttable/

Current Version: SortTable version 2, 7th April 2007

Instructions

To make a table of your choice sortable, there are two steps:

  1. Include the SortTable: Make tables sortable Javascript library, add it in a foot_content property or object, like so:
    <script src="/Javascript/SortTable/sorttable.js" type="text/javascript"></script>
  2. Mark your table as a sortable one by the class "sortable" to it:
    <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).

And that's all you need. Your table will now have column sorting available by clicking the headers. To make the feature more visible to the user, you might want to add the following styles to your local.css stylesheet, or make up some of your own based on this:

/* Sortable tables */
table.sortable thead {
  background-color:#eee;
  color:#666666;
  font-weight: bold;
  cursor: default;
}