Sorting numbers with point separator for thousand (1.999,99 €)

Sorting numbers with point separator for thousand (1.999,99 €)

SisernikSisernik Posts: 8Questions: 0Answers: 0
edited August 2011 in Blog
Hi,

Here is EURO currency sorting:

jQuery.fn.dataTableExt.oSort['slo-asc'] = function(a,b) {
var x = (a == "-") ? 0 : a.replace( /\./g, "" ).replace( /,/, "." );
var y = (b == "-") ? 0 : b.replace( /\./g, "" ).replace( /,/, "." );
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['slo-desc'] = function(a,b) {
var x = (a == "-") ? 0 : a.replace( /\./g, "" ).replace( /,/, "." );
var y = (b == "-") ? 0 : b.replace( /\./g, "" ).replace( /,/, "." );
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};




$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
null,
{ "sType": "slo" },
]
} );
} );
This discussion has been closed.