madan_hytech wrote:
> 
> Hi,
> 
> I have used Jquery TableSorter to sort text on client side its working
> fine except following issue.
> 
> “Sort on area is not correct for Scandinavian chars, the Scandinavian
> letters shall be in this order – æ ø å and for capitalized it is Æ Ø Å”
> 
> Currently, the text is sorting in English language, is there any
> possibility to sort the data in culture based or do you have another
> solution to fix this issue.
> 
> Please revert back with the solution ASAP.
> 
> Thanks in advance :)
> 
> 

The default stringcomparer in javascript uses Latin1, which doesn't work
properly for scandinavian characters. In order to get the kind of sort you
are looking for, you have to change two functions in the tablesorter script:

function sortText(a,b) {
        //return ((a < b) ? -1 : ((a > b) ? 1 : 0));
        return a.toString().localeCompare(b.toString());                        
        
};
                        
function sortTextDesc(a,b) {
        //return ((b < a) ? -1 : ((b > a) ? 1 : 0));
        return b.toString().localeCompare(a.toString());
};      

This will sort the text using the browsers current culture. So if the users
browser is set to a scandinavian culture, it will function correctly. If the
users browser is in english, then they will not see any difference.

I hope this helps.
-- 
View this message in context: 
http://www.nabble.com/sort-not-work-properly-in-Scandinavian-character-tp24034604s27240p25066102.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to