Shawn M. P. Hill

Sortable table Script

I found this script on http://www.kryogenix.org a site for and by Stuart Langridge, and thought it was really uesful but needed some tweaks. I changed the following:

  • Moved all presentation information into the css file. Including the sort indicator, which is now a background image set in a class selector.
  • Changed the sort trigger from link to table header onclick event.
  • Added rollover state to table headers.
  • Made the column type parsing code a bit more forgiving by using the isNaN fn() and less strict date matching reg ex.
  • Changed the date sorting function to use the Javascript Date function. Can now use either mm dd yyy or dd mm yyy by setting the variable monthBeforeDay. Also can now set the cut off year for two digit year conversion.
  • Added ability to have multiple tables on the sam page.

Here is the juice:

  String String and Int Int and String Numeric Fraction
Edit Howdy Word 123 123 Word 2314 2314.1234
Edit What Up? a1 123q 9874 9846.54
Edit Que Pasa qweq1weqwe 11 2d 546 35494.654
Edit Hey There pppp 456 18.9 asdf 1 9898.
Edit Ahoy clown 413 21 Jump Street 99999 6.354
Edit Pardon me girl39 1137 Vermont 32 0.6477
Edit By the way post 64 911 Main 123 1.0
Edit XYZ! Word 456 654 avve 987 987.654
Edit The cat Word 789 543 afsafsadf 532 546.65798
Edit another think Word 9 777 Landon 66 53.1234
Very Nice, Yes?
String MM/DD/YY MM-DD-YY MM/DD/YYYY Dollars
Howdy 1/12/99 1-12-99 3/30/2001 $19.99
What Up? 1/1/99 1-1-99 9/18/1999 $27.50
Que Pasa 12/11/99 12-11-99 12/1/2006 $1000
Hey There 12/9/99 12-9-99 9/30/2100 $49.99
Ahoy 6/18/50 6-18-50 7/12/1900 $22,000.23
Pardon me 1/12/70 1-12-70 10/31/2003 $190,254.32
By the way 10/1/80 10-1-80 11/22/2003 $2
XYZ! 8/12/20 8-12-20 4/4/1950 $.50
The cat 9/29/03 9-29-03 12/12/2005 $48.72
another think 1/12/20 1-12-20 11/21/2003 $17.94
Updated 11-22-2003