Created
October 29, 2013 10:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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