Reputation: 37
orderBy places national/accented characters at the end
a b c o u z á č ů ž
in my language (Czech) correct order should be
a á b c č o u ů z ž
any way to make Vue sort like this? thanks
Upvotes: 1
Views: 465
Reputation: 386728
You can take the sort mechanism of Javascript with String.prototype.localeCompare()
and the locales
parameter.
var array = ['a', 'b', 'c', 'o', 'u', 'z', 'á', 'č', 'ů', 'ž'];
array.sort(function (a, b) {
return a.localeCompare(b, 'cz');
});
document.write('<pre>' + JSON.stringify(array, 0, 4) + '</pre>');
Upvotes: 2