So I was wandering around the internet searching for some sorting function in js. Here is the problem. We have a string array like this :
['único', 'UNICO', 'árbol', 'ARBOL', 'cosas', 'COSAS', 'fútbol', 'FUTBOL']
and we want somthing like this (Uppercase first):
['ARBOL', 'COSAS', 'FUTBOL', 'UNICO', 'árbol', 'cosas', 'fútbol', 'único']
or like this (lowercase first):
['árbol', 'cosas', 'fútbol', 'único', 'ARBOL', 'COSAS', 'FUTBOL', 'UNICO']
The thing is : it's really easy to get this :
['ARBOL', 'COSAS', 'FUTBOL', 'UNICO', 'cosas', 'fútbol', 'árbol','único']
with the .sort();
function but we don't want the accentuated words at the end so we use the
.sort(function(a, b) {
return a.localCompare(b);
});
but we end up with this ...
['ARBOL', 'árbol', 'COSAS', 'cosas', 'FUTBOL', 'fútbol', 'UNICO', 'único']
Do you guys have any idea on how to combine both ?