Skip to content

Instantly share code, notes, and snippets.

@csessig86
Created November 5, 2013 22:58
Show Gist options
  • Save csessig86/7327877 to your computer and use it in GitHub Desktop.
Save csessig86/7327877 to your computer and use it in GitHub Desktop.
Format number column with DataTables
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"formatted-num-pre": function ( a ) {
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;
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment