Angular sorts "Åland Islands" after "Zimbabwe". I would like to fix this in a global way. Rather than creating a custom sort function and specifying it in every orderBy filter, I would like to somehow globally patch the default sort function. Is this possible?
By first normalizing both strings with the following function, the problem is fixed:
function norm(str) {
str = str.toLowerCase();
str = str.replace(/\\s/g, "");
str = str.replace(/[àáâãäå]/g, "a");
str = str.replace(/æ/g, "ae");
str = str.replace(/ç/g, "c");
str = str.replace(/[èéêë]/g, "e");
str = str.replace(/[ìíîï]/g, "i");
str = str.replace(/ñ/g, "n");
str = str.replace(/[òóôõö]/g, "o");
str = str.replace(/œ/g, "oe");
str = str.replace(/[ùúûü]/g, "u");
str = str.replace(/[ýÿ]/g, "y");
str = str.replace(/\\W/g, "");
return str;
}
I'm hoping there's a way to do this once in Angular and never worry about it again.
betterOrderBybehaves the same asorderBy.