jQuery dataTable sorting with international characters

If you need to automatically sort jQuery datatable columns including international characters or date/date-time in European format you can use following code:

jQuery.fn.dataTableExt.aTypes.unshift(
   //Comparator/Formatter selection function
    function (sData) {
        if (sData !== null && sData.match(/^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20|21)\d\d$/)) {
            return 'date-eu';
        }
	if (sData != null && sData.match(/^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20|21)\d\d \d{1,2}:\d\d$/)) {
  	    return 'datetime-eu';
	}		
	if (sData !== null && sData.toUpperCase().match(/^.*[A-Za-zÁČĎÉÍĹĽŇÓÔŔŘŠŤÚŮÝŽ].*/)) {
    		return 'czech-string';
    	}
        return null;
    }
);

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
      
    "czech-string-pre" : function( czechString) {    
        //removes hyperlink  encapsulation of the text  
    	var czechString = czechString.replace( /<.*?>/g, "" );    
        return czechString;
    },
    
    "czech-string-asc" : function(a, b) {
        return a.localeCompare(b);
    },
     
    "czech-string-desc" : function(a, b) {
        return b.localeCompare(a);
    },
    
    /** Date comparators/formatters */
    "date-eu-pre": function ( date ) {
        var date = date.replace(" ", "");
          
        if (date.indexOf('.') > 0) {
            /*date a, format dd.mn.(yyyy) ; (year is optional)*/
            var eu_date = date.split('.');
        } else {
            /*date a, format dd/mn/(yyyy) ; (year is optional)*/
            var eu_date = date.split('/');
        }
          
        /*year (optional)*/
        if (eu_date[2]) {
            var year = eu_date[2];
        } else {
            var year = 0;
        }
          
        /*month*/
        var month = eu_date[1];
        if (month.length == 1) {
            month = 0+month;
        }
          
        /*day*/
        var day = eu_date[0];
        if (day.length == 1) {
            day = 0+day;
        }
          
        return (year + month + day) * 1;
    },    
    "date-eu-asc": function (a, b) {
        return ((a < b) ? -1 : ((a > b) ? 1 : 0));
    },
 
    "date-eu-desc": function ( a, b ) {
        return ((a < b) ? 1 : ((a > b) ? -1 : 0));
    },
    /** Datetime comparators/formatters */
    "datetime-eu-pre": function ( ldate ) {
	var dateandtime = ldate.split(' ');
	var dates = dateandtime[0].split('.');
	var times = dateandtime[1].split(':');
	var hours = times[0].lenght == 1 ? "0" + times[0] : times[0];
	return dates[2] + dates[1] + dates[0] + hours  + times[1];
    },
    "datetime-eu-asc": function ( a, b ) {
        return ((a < b) ? -1 : ((a > b) ? 1 : 0));
    },
 
    "datetime-eu-desc": function ( a, b ) {
        return ((a < b) ? 1 : ((a > b) ? -1 : 0));
    }                
} );