Please help me with sorting.

Please help me with sorting.

nandrainandrai Posts: 26Questions: 0Answers: 0
edited December 2012 in General
the following code is not sorting when it has comma in it, other wise it is working fine. it you take out the comma from the following code it is working as expected.


the data is when sorted as desc

[quote]
-2,598.00
-3,493.70
-350.00
-36.00
-435.75
-8,200.00
0.00
0.00
17,444.00
27,200.00
736.75
[/quote]


[code]

jQuery.extend( jQuery.fn.dataTableExt.oSort, {

"formatted-num-pre": function ( a ) {

a = (a==="-") ? 0 : a.replace( /[^\d\-\.]/g, "" );
return parseFloat( a );

},

"formatted-num-asc": function ( a, b ) {
return a - b;
},


"formatted-num-desc": function ( a, b ) {
return b - a;
}

} );



/* Table initialisation */
$(document).ready( function() {
$('#myTable').dataTable( {
"sPaginationType": "full_numbers",
"aoColumns": [null,null,null,null,null,{ "sType": "formatted-num" }, null,null]
} );
} )

[/code]
This discussion has been closed.