simple jquery table sort
requires jquery.sortElements.js (https://github.com/jamespadolsey/jQuery-Plugins/blob/master/sortElements/jquery.sortElements.js)
via http://stackoverflow.com/questions/3160277/jquery-table-sort
1 var table = $('table'); 2 3 $('th').wrapInner('<span title="Sort this column"/>').each(function(){ 4 var th = $(this), thIndex = th.index(), inverse = false; 5 th.click(function(){ 6 table.find('td').filter(function(){ 7 return $(this).index() === thIndex; 8 }).sortElements(function(a, b){ 9 return $.text([a]) > $.text([b]) ? 10 inverse ? -1 : 1 11 : inverse ? 1 : -1; 12 }, function(){ 13 return this.parentNode; 14 }); 15 inverse = !inverse; 16 }); 17 });