JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.21.2/js/jquery.tablesorter.min.js"></script>
<table id="users" class="tablesorter">
<thead>
<th>id</th>
<th>name</th>
</thead>
<tbody>
<tr>
<td>1,040</td>
<td>name1</td>
</tr>
<tr>
<td>1,050</td>
<td>name2</td>
</tr>
<tr>
<td>1,060</td>
<td>name3</td>
</tr>
<tr>
<td>1,100</td>
<td>name4</td>
</tr>
<tr>
<td>1,200</td>
<td>name5</td>
</tr>
</tbody>
</table>
JavaScript
$(function() {
$.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"
});
$("#users").tablesorter({
widgets: ['zebra'],
headers: {
0: {
sorter: 'fancyNumber'
}
}
});
});