Sorting datatable columns

215 views Asked by At

I have datatable column which has negative as well as positive numbers, I need to sort them in ascending order i.e (negative values first) followed by positive values -

Here is my sort method -

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"num-html-pre": function ( a ) {
   // var x = String(a).replace(/(?!^-)[^0-9.]/g, "");
    return parseFloat( a );
},

"num-html-asc": function ( a, b ) {
    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},

"num-html-desc": function ( a, b ) {
    return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});

I just dont understand what is wrong here.

0

There are 0 answers