Checkboxes parser for jQuery Tablesorter plugin

Because i was looking for a way to sort a table i found Tablesorter for jQuery.

There was only 1 problem. It did not sort correctly when the table cells contained checkboxes.

After a lot of Googling i found this solution:

$.tablesorter.addParser({
 id: 'checkboxes',
 is: function(s) {
 return s.toLowerCase().match(/<input[^>]*checkbox[^>]*/i);
 },
 format: function(s,table,cell) {

 var checked = $(cell).children(":checkbox").get(0).checked;    

 return  checked  ? 1 : 0;

 },
 type: "numeric"
 });

Ofcourse you need the Tablesorter plugin for jQuery and jQuery itself.