Cannot get customized table sort to work
Hi,
I'm using a bog-standard tablesorter (from
http://tablesorter.com/ ) and I'm trying to sort on months using a custom parser:
- /* */
jQuery.tablesorter.addParser({
id: "mm",
is: function (s)
{
return false;
},
format: function (s)
{
return s.tolowercase().replace(/december/g ,12).
replace(/november/g ,11).
replace(/october/g ,10).
replace(/september/g, 9).
replace(/august/g , 8).
replace(/july/g , 7).
replace(/june/g , 6).
replace(/may/g , 5).
replace(/april/g , 4).
replace(/march/g , 3).
replace(/february/g , 2).
replace(/january/g , 1);
},
type: "numeric"
});
but for whatever reason, that doesn't seem to work, so right now I'm working around the problem by using a bit of trickery with hidden elements, i.e.
- <table id="mnthtable" class="tablesorter">
<thead class="mnth">
<tr>
<th>mMonth
<th>Days
<th>Distance
<th>Time
<th>Speed
</thead>
<!-- 0 1 2 3 4 -->
<tbody class="mnth">
<tr><td>aJanuary <td> 34 <td> 24,220.5 <td> 221:23<td>109.4
<tr><td>bFebruary <td> 43 <td> 29,628.5 <td> 260:54<td>113.6
<tr><td>cMarch <td> 32 <td> 23,606.6 <td> 221:30<td>106.6
<tr><td>dApril <td> 53 <td> 38,198.1 <td> 356:03<td>107.3
<tr><td>eMay <td> 74 <td> 60,218.6 <td> 569:47<td>105.7
<tr><td>fJune <td> 96 <td> 66,829.0 <td> 673:18<td> 99.3
<tr><td>gJuly <td> 97 <td> 67,300.7 <td> 684:18<td> 98.3
<tr><td>hAugust <td> 105 <td> 70,171.3 <td> 677:24<td>103.6
<tr><td>iSeptember <td> 101 <td> 69,652.2 <td> 666:52<td>104.4
<tr><td>jOctober <td> 60 <td> 37,786.7 <td> 353:38<td>106.9
<tr><td>kNovember <td> 42 <td> 30,919.4 <td> 288:02<td>107.3
<tr><td>lDecember <td> 28 <td> 20,678.1 <td> 194:29<td>106.3
</tbody>
</table>
where the CSS for the table looks like
- thead.mnth tr th:nth-child(1)::first-letter {
color: #e8e8e8;
font-family: monospace;
font-size: inherit;
}
tbody.mnth tr td:nth-child(1)::first-letter {
color: #f8f8f8;
font-family: monospace;
font-size: inherit;
}
which works nicely, but obviously there should be a better way.
Can anyone tell me what I'm doing wrong? The actual page using the table is https://prino.neocities.org/log/summary.html It's the last table on the page.