title: Custom Parser for Tablesorter plugin for custom date format
body: <p>I need to adapt the jQuery Tablesorter plugin to sort dates in a very simple format which will consist of the three letter month and the 4 digit date (e.g. May 2010, Jan 2011, Mar 2012, etc).</p>
  
  <p>I have'nt been able to wrap my head around how to do it. I tried adapting the parser found here: <a href="http://beausmith.com/blog/custom-date-sorting-for-jquery-tablesorter-plugin/" rel="nofollow">http://beausmith.com/blog/custom-date-sorting-for-jquery-tablesorter-plugin/</a>. But I am lost with reg ex. For ease in helping, I will post his code below.</p>
  
  <pre><code>// TableSort parser for date format: Jan 6, 1978
  $.tablesorter.addParser({
  id: 'monthDayYear',
  is: function(s) {
    return false;
  },
  format: function(s) {
    var date = s.match(/^(\w{3})[ ](\d{1,2}),[ ](\d{4})$/);
    var m = monthNames[date[1]];
    var d = String(date[2]);
    if (d.length == 1) {d = "0" + d;}
    var y = date[3];
    return '' + y + m + d;
   },
  type: 'numeric'
  });
  var monthNames = {};
  monthNames["Jan"] = "01";
  monthNames["Feb"] = "02";
  monthNames["Mar"] = "03";
  monthNames["Apr"] = "04";
  monthNames["May"] = "05";
  monthNames["Jun"] = "06";
  monthNames["Jul"] = "07";
  monthNames["Aug"] = "08";
  monthNames["Sep"] = "09";
  monthNames["Oct"] = "10";
  monthNames["Nov"] = "11";
  monthNames["Dec"] = "12";
  </code></pre>
  
  <p>Any ideas on how to just format it for month names and year? Thanks!</p>
  
  <p>UPDATE:
  I have tried to implement some code both from Sam and Fudgey below (thank you for being so helpful thus far!). I can't quite get it to work. I tried to use fugey's code sample because I see where it is working exactly as needed on the fiddle demo. Below is my HTML markup:</p>
  
  <pre><code>&lt;table id="myTable" class="stripeMe sample" width="100%" cellpadding="0"    cellspacing="0"&gt;
  &lt;thead&gt;
  &lt;th width="30%" align="left"&gt;COMPANY&lt;/th&gt;&lt;th width="35%"&gt;DESCRIPTION&lt;/th&gt;&lt;th width="17%"   align="left"&gt;INDUSTRY&lt;/th&gt;&lt;th width="18%" align="left"&gt;EXIT DATE&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
  &lt;tr&gt;&lt;td width="30%"&gt;   &lt;a href="http://www.cartera.com/vesdia.html "&gt; Cartera Commerce,  Inc.&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Provides technology-enabled marketing and loyalty solutions 
  &lt;/td&gt;&lt;td width="17%"&gt;   Financials  &lt;/td&gt;&lt;td width="18%"&gt;Feb 2010&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td  width="30%"&gt;   &lt;a href="http://www.criticalinfonet.com/ "&gt; Critical Information Network,   LLC&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Operates library of industrial professional training and certification   materials 
  &lt;/td&gt;&lt;td width="17%"&gt;   Education  &lt;/td&gt;&lt;td width="18%"&gt;Apr 2011&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td     width="30%"&gt;   &lt;a href="http://www.cynergydata.com/ "&gt; Cynergydata&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Provides merchant payment processing services and related software products 
  &lt;/td&gt;&lt;td width="17%"&gt;   Merchant Processing  &lt;/td&gt;&lt;td width="18%"&gt;May 2011&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td width="30%"&gt;   &lt;a href=" "&gt; EVCI Career Colleges Holding Corp&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Operates post-secondary schools  
  &lt;/td&gt;&lt;td width="17%"&gt;   Education  &lt;/td&gt;&lt;td width="18%"&gt;Jul 2012&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td  width="30%"&gt;   &lt;a href="http://www.groundlink.com/ "&gt; Groundlink, Inc.&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Provides ground transportation services domestically and internationally 
  &lt;/td&gt;&lt;td width="17%"&gt;   Transportation  &lt;/td&gt;&lt;td width="18%"&gt;Feb 2012&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td  width="30%"&gt;   &lt;a href="http://www.haggen.com/ "&gt; Haggen, Inc.&lt;/a&gt;  &lt;/td&gt;
  &lt;td width="35%"&gt;Operates chain of high-end grocery stores in the Pacific Northwest 
  &lt;/td&gt;&lt;td width="17%"&gt;   Grocery  &lt;/td&gt;&lt;td width="18%"&gt;Aug 2011 &lt;/td&gt;&lt;/tr&gt;
  
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And then the script I am using, which is fudgey's but I changed the column header number to 3 (it's the 4th column in my table) and I changed the call to the tablesorter to use the id of the table, which in this case is the ever original #myTable. I also wrapped it in jQuery's $(document).ready:</p>
  
  <pre><code>$(document).ready(function() { 
  $.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 &amp;&amp; date[2] ? date[2] || '' : '';
  return new Date(m + y).getTime() || '';
  },
  type: 'Numeric'
  });
  
  $('#myTable').tablesorter({
  headers: {
      3: {
          sorter: 'monthYear'
      }
  }
  });
  });
  </code></pre>
  
  <p>And it is still not sorting that column by date, I'm not sure how it is sorting it - I get a sort in this order, which almost seems right but look at where that Feb 2010 falls, right in the middle of 2011 dates - weird: 
  Aug 2011
  Feb 2010
  Apr 2011
  May 2011
  Feb 2012
  Jul 2012</p>