sorting
HTML
<table id="caltbl">
<thead>
<tr>
<th>
</th>
<th>
Date
</th>
<th>
hours
</th>
<th>
Module
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sortnr">4</td>
<td></td>
</tr>
<tr>
<td class="sortnr">1</td>
<td></td>
</tr>
<tr>
<td class="sortnr">3</td>
<td></td>
</tr>
<tr>
<td class="sortnr">2</td>
<td></td>
</tr>
</tbody>
</table>
JavaScript
$(document).ready(function(){
var rows = $('table#caltbl > tbody').children('tr').detach();
//sort using comparison function - based on Int
rows.sort(function(row1, row2){
return parseInt($(row1).find(".sortnr").text()) - parseInt($(row2).find(".sortnr").text());
});
//repaste the rows in correct order.
$(rows).each(function(){
$('#caltbl > tbody:last').append($(this));
});
});