Author: icvav
Description:
I'am a user of spanish wikipedia and the sorting script doesn't sort properly
strings with spanish characters: á, é, í, ó, ú, ü, ñ, Á, É, Í, Ó, Ú, Ü, Ñ.
Example: ñu, águila, barco, nada, obra
Expected Results:
1.- águila
2.- barco
3.- nada
4.- ñu
5.- obra
Actual Results:
1.- barco
2.- nada
3.- obra
4.- águila
5.- ñu
Solution could be:
function ts_sort_caseinsensitive(a,b) {
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
return(aa.localeCompare(bb));
}
Now this function is:
function ts_sort_caseinsensitive(a,b) {
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
if (aa==bb) {
return 0;
}
if (aa<bb) {
return -1;
}
return 1;
}
I've tried it on my PC and it seems work.
Another possible solution can be use the replace function to replace: á ->a,
é->e, í->i, ó->o, ú->u, ü->u, ñ->nz, ... And then sort them.
Other languages could need similar changes.
Version: unspecified
Severity: normal