Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jon Evans on Jun 10, 2008 05:28
open dhtmlx forum
bugs in your case insensitive sorting example in the docs

In your case insensitive sorting example there are three bugs.

1) the function definition:

function str_custom=function(a,b,order)

obviously should be just:

str_custom=function(a,b,order)

2) the sorting comparisons:

if (order=="asc")
return (a.toLoweCase()>b.toLoweCase()?1:-1);
else
return (a.toLoweCase()<b.toLoweCase()?-1:1);

should be toLowerCase() not toLoweCase()

3) the sorting comparisons:

you've switched the direction of both the comparison operator and the return values. So both ascending and descending sort will be identical. A working version:

str_custom=function(a,b,order) {
if (order=="asc")
return (a.toLowerCase() > b.toLowerCase() ? 1 : -1);
else
return (a.toLowerCase() > b.toLowerCase() ? -1 : 1);
}
Answer posted by Support on Jun 10, 2008 07:57
We will updated online document in nearest time, sorry for inconvenience.
Answer posted by Michael on Jul 16, 2009 09:37
Thanks John, They still haven't fixed the online example.  Glad I found this.  I spotted the toLowerCase issue but was wondering why desc sort was not working.  Good catch!
Answer posted by Michael on Jul 16, 2009 09:38
Sorry I mean Thanks Jon. :)
Answer posted by Michael on Jul 16, 2009 14:16
Sorry I mean Thanks Jon. :)