Skip to content

Instantly share code, notes, and snippets.

@munen
Created October 29, 2013 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save munen/7212001 to your computer and use it in GitHub Desktop.
Save munen/7212001 to your computer and use it in GitHub Desktop.
Sort Datatables content following DIN5007, variant 1 http://de.wikipedia.org/wiki/Alphabetische_Sortierung
// By default Datatables uses the sType 'html' for its cells and sorting.
// Therefore the sort mechanism for this sType is overwritten here as seen here:
// http://datatables.net/development/sorting#type_based
din5007Relacement = function(x) {
x = x.replace("ä", "a");
x = x.replace("ö", "o");
x = x.replace("ü", "u");
x = x.replace("ß", "ss");
return x;
}
$.fn.dataTableExt.oSort['html-asc'] = function ( x, y ) {
x = din5007Relacement(x);
y = din5007Relacement(y);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
$.fn.dataTableExt.oSort['html-desc'] = function ( x, y ) {
x = din5007Relacement(x);
y = din5007Relacement(y);
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment