format: function (table) { $('tbody tr', table).each(function (index) { $(this).find('td:first').html((index + 1)); }); } }); tablesorter.addWidget({ id: "evenRowClasses", format: function (table) { $('tbody tr', table).each(function (index) { if ((index + 1) % 2 == 0) { $(this).addClass("even"); } else { $(this).removeClass("even"); } }); } }); tablesorter.addParser({ id: "fancyNumber", is: function (s) { return /^[0-9]?[0-9,\.]*$/.test(s); }, format: function (s) { return tablesorter.formatFloat( s.replace(/,/g,'') ); }, type: "numeric" });
$('tbody tr', table).each(function (index) { if ((index + 1) % 2 === 0) { $(this).addClass('even'); } else { $(this).removeClass('even'); } }); }, id: 'evenRowClasses', }); tablesorter.addParser({ format: function (s) { return tablesorter.formatFloat(s.replace(/,|\.|\s/g, '')); }, id: 'fancyNumber', is: function (s) { return /^[0-9]?[0-9,.]*$/.test(s); }, type: 'numeric', }); $('#countries-table').tablesorter({ headers: { [0]: {sorter: false}, [2]: {sorter: 'fancyNumber'}, [3]: {sorter: 'fancyNumber'}, [4]: {sorter: 'fancyNumber'}, [5]: {sorter: 'fancyNumber'}, }, // order by descending number of entities, then name sortList: [[5, 1], [1, 0]],