---
title: "Jquery sort table number"
author: "夜鸣猪"
date: "2013-03-19T01:01:50Z"
tags: []
categories: ["编程语言"]
slug: "jquery-sort-table-number"
draft: false
lastmod: "2013-03-19T01:01:50Z"
id: 1831545
url: "https://hlee.iteye.com/blog/1831545"
---

So here is what the column is sorted as:

    4,666
    141,666
    293
    341,666
    346
    461,676

This should be sorted as

    293
    346
    4,666
    141,666
    341,666
    461,676




```js
$(document).ready(function() {
      $.tablesorter.addParser({
        id: 'fancyNumber',
        is:function(s){return false;},
        format: function(s) {return s.replace(/[\,\.]/g,'');},
        type: 'numeric'
    });
    $("table").tablesorter({headers: {0: {sorter: 'fancyNumber'}}});
});
```