Sortable Table 1.

Alpha Content Numeric Date Money Not Sorted Custom Sort
String 1 1 06/01/09 $120.00 Not Sorted Tuesday
String 2 8 05/01/09 $100.00 Not Sorted Monday
String 3 5 05/11/09 $110.00 Not Sorted Sunday
String 4 -2 06/11/09 $10.00 Not Sorted Friday
String 5 -6 06/11/08 $10.01 Not Sorted Friday
Browser Support:
FF2.x >, IE6-8, Opera >= 9.6, Safari4.0 (for Windows)
This is the list of the browsers where this table was tested.
In reality this list is probably much longer.
Restrictions:
This technique doesn't support:
1. Tables with a broken murkup.
2. Tables with more that one row in the thead part.
3. Different number of the COLSPAN in the thead and tbody parts.
(see explanation of these restrictions: colspan, rowspan problem).
Initialization:
1. Include sortedTable.js into html head.
2. Add some ID to this table (in my case it is 'table_1').
3. At the bottom of your HTML add next javascript code:
<script>
	var config = {
		tableId:'table_1', // the only mandatory parameter
		even_row:'b', 
		odd_row:'a'
	}
	var t1 = new Chth.sortTable();
	t1.init(config);
	// or Chth.sortTable().init(config); 
	// instead of last 2 lines.
</script>
Where the tableId is the ID of this table, the even_row and odd_row are existing css classes for a stripped table (default are 'row_a' and 'row_b').
This table can be sorted by any column.
To sort it click on any header column.
The first click will sort this table by this column in ascending order.
The second (third, forth, ...) one will revert the table (no sorting, that is much faster).
It knows nothing about a server sorted stage, and if for example, the table is presorted by the first column in ascending order, the first click on this column still sorts table by this field in ascending order (I'll show how to work around this problem in the 'Sortable Table 2').
The data type of each column has auto detection mechanism.
If you have some columns that must be sorted with some particular algorithm you have to specify the type of the sorting manually. What does it mean? For example if your column has value 345345, the auto detector will assign the numeric sorting for this column. If you want to sort this column as a string, add class="sorttable_alpha" in the header line for this column.
Currently supported data types are:
	sorttable_alpha
	sorttable_numeric
	sorttable_mmdd
	sorttable_ddmm
	sorttable_nosort
In case of the 'sorttable_nosort' this column will lose a possibility to trigger sorting mechanism, the mouseover even will not change the cursor. (Column: 'Not Sorted').
Default sorting algorithm for the date string like that: 01/01/2009 is sorttable_mmdd. If it is not correct you should put for this column class="sorttable_ddmm".
The money data type is recognizing by the auto detection as the sorttable_numeric function.
There is very powerful mechanism that allows to use a custom sorting. How it works?
For example in the table you have a column that contains the week days: Mon, Tue,... and you want to sort this column in the reasonable order.
Use: sorttable_customkey
	<tr><td sorttable_customkey="1">Mon<td>...
	<tr><td sorttable_customkey="5">Fri<td>...
In this case the column will be sorted not by visible data but by the sorttable_custom value instead! (column: 'Custom Sort').
The cursor is changing for 'wait' during a sorting and reordering rows.
The arrow images every time indicate the order of the sorting for last sort.

But it is not whole story. If you add only one more argument during initialization of your table

var config = {
	tableId:'table_1',
	even_row:'b',
	odd_row:'a',
	sortMap: '1, 2, 3:desc'
}
the ability for sorting will dramatically increase. See next page: Sortable Table 2.