Unobtrusive and with alternating row colors
Ramon Eijkemans pointed me to a script written by Stuart Langridge. This unobtrusive table sorting script was awesome, offering sort mechanisms for text, numbers, dates and currencies, by simply adding an external script to a page and a class to a table!
However, it lacked a few things, most importantly: support for alternated row classes. Working on it more, I found there were a few bugs to it too. So I started adapting it. At first there were just a few changes. Now more and more e-mails with feature requests are coming in, and I have started versioning my table sorting script.
Example table
Click on the headings to sort the table.
| Numbers | Alphabet | Dates | Currency | Unsortable |
|---|---|---|---|---|
| 1 | Z | 02-02-2004 | €5.00 | This |
| 2 | y | 13-apr-2005 | Row | |
| 3 | X | 17.aug.2006 | €6.50 | Is |
| 4 | w | 01.Jan.2005 | €4.20 | Unsortable |
| 5 | V | 05/12/2006 | €7.15 | See? |
| 15 | €29.55 |
Quick start guide to sorting your tables
To get this script working, download the script, and add it to the head section of your webpage like this:
<script type="text/javascript" src="sortable.js"></script>
Then add class="sortable" and an id, for instance id="sortabletable" to the table you want to sort, and you’re all done.
If you need more info, go to the tutorial.
License and download for the sortable table script
The table sorting javascript is MIT licensed, so feel free to use it.
As of version 1.2.1, a European and an American version are available for download, to make it easier for people to start using it with the right date sorting method. Download it here:
- ZIP package, including the script in normal and US version, examples and sort images (8kb);
- Just the script, unzipped (9kb);
- Just the script, US version, unzipped (9kb);
Help me to improve your table sorting options!
It takes an awful lot of time to maintain scripts like these properly, and while I’m not charging, and won’t ever charge, anyone for the use of the script, if you like and use it, I’d appreciate a donation! You can donate using PayPal or buy me a book from my wishlist, if you have something else you’d like to give or send me, email me.