Problem sorting DataView

Hi. I have a problem while sorting a DataView. In Spain we have some letters like á, é, í, ó, ú and ñ that results placed at the end after sorting. The 5 accented vowels must be placed as normal vowels, and the ‘ñ’ must be between the ‘n’ and the ‘o’. How can I do that?

Thank you.

Hi,

You should use custom sorting:

[code]function replaceAccented (text){
var chars = {“á”:“a”, “é”:“e”, “í”:“i”,“ó”:“o”, “ú”:“u”, “ñ”:“n”};
for(var c in chars){
text = text.toString().replace(new RegExp(c, “g”), chars[c]);
}
return text;
}

dataView.sort(function(a,b){
var nameA = replaceAccented(a.name);
var nameB = replaceAccented(b.name);
return nameA > nameB ?1:-1;
},“asc”);[/code]

I only have 1 name per item in the DataView (#Name# or {obj.Name}), but it seems you use parameters A and B in the function to compare one each other. How can I do that?

Thank you.

a and b - two different items from dataview. The sorting function that I described in the previous reply is the same as usual approach to sort array of objects in JavaScript.

Very grateful for your help. Now I understood. Sorry I made ​​a stupid question, but my knowledge of JavaScript are not very good yet.

Best wishes.

No worries ) I was happy to help.