Fixed: http://tablesorter.com/ query
I am using the
http://tablesorter.com/ plugin to sort data in a table.
This is a simple page:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript" src="http://tablesorter.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://tablesorter.com/jquery.tablesorter.js"></script>
<script type="text/javascript" id="js">
$(document).ready(function() {
// call the tablesorter plugin
$("table").tablesorter({
// sort on the first column and third column, order asc
sortList: [[0,0]]
});
});
</script>
<title>Test</title>
</head>
<body>
<table border="1" class="tablesorter">
<thead>
<tr>
<th style="width:30px;">Num</th>
<th>Instance</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>PROD</td>
<td>28/03/2011</td>
</tr>
<tr>
<td>2</td>
<td>PROD2</td>
<td>18/02/2011</td>
</tr>
<tr>
<td>3</td>
<td>PROD3</td>
<td>02/10/2010</td>
</tr>
<tr>
<td>4</td>
<td>PROD4</td>
<td>30/12/2010</td>
</tr>
</tbody>
</table>
</body>
</html>
Problem is that when I sort on date, it doesn't sort in data order, just by the first number, so if I sort via descending date, I get this:
28/03/2011
30/12/2010
18/02/2011
02/10/2010
Instead of:
28/03/2011
18/02/2011
30/12/2010
02/10/2010
I can see via the docs:
http://tablesorter.com/docs/example-parsers.html
That you can use parsers, and there is something to do with iso-dates, but I can't work out how to use that in the HTML page above to sort via the data column properly.
Any advice much appreciated.
Thanks