Tablesorter demo

All options included, as well as the uitheme widget

by Mottie

HTML

<link rel="stylesheet" href="http://mottie.github.com/tablesorter/css/blue/style.css">
<script src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>
<script src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.widgets.js"></script>
<table class="tablesorter">
    <thead>
        <tr><th>Date</th></tr>
    </thead>
    <tbody>
        <tr><td>Jan 2012</td></tr>
        <tr><td>Sep 2011</td></tr>
        <tr><td>Mar 2012</td></tr>
        <tr><td>Feb 2011</td></tr>
        <tr><td>Feb 2012</td></tr>
        <tr><td>Dec 2012</td></tr>
        <tr><td>May 2012</td></tr>
    </tbody>
</table>

JavaScript

$.tablesorter.addParser({
    id: 'monthYear',
    is: function(s) {
        return false;
    },
    format: function(s) {
        var date = s.match(/^(\w{3})[ ](\d{4})$/);
        var m = date ? date[1] + ' 1 ' || '' : '';
        var y = date && date[2] ? date[2] || '' : '';
        return new Date(m + y).getTime() || '';
    },
    type: 'Numeric'
});

$('table').tablesorter({
    headers: {
        0: {
            sorter: 'monthYear'
        }
    }
});