stable sort with custom functions

Hi,



I have found your informations about custom sorting function and the hint about the unstable and stable sorting routine.

Because I need the stable sorting I have called the enableStableSorting() function and get an error message. After integrating the patch provided in the post dhtmlx.com/docs/products/kb/inde … bleSorting

the stable sorting works fine in predefined sort orders (str, int…)



But it doesn’t work in custom functions like your str_custom or date_custom.

Is there a possibility to use the stable sorting in custom sort functions?



By the way: in your custom date sorting function is an error



a=a.split("/")

b=a.split("/")



I think it must be



a=a.split("/");

b=b.split("/");



isnt’t it?



Regards



Dirk

isnt’t it?
Yes, documentation will be updated in nearest time.

>>Is there a possibility to use the stable sorting in custom sort functions?
For dhtmlxgrid 1.6+ the enableStableSorting affects both built-in and custom sorting functions ( not so sure for earlier versions )
The problem may be in sorting function , it need to be a bit more complex.

function date_custom=function(a,b,order){
if (a==b) return 0; //the 0 must be returned for case, when values are equal
a=a.split("/")
b=b.split("/")
if (a[2]==b[2]){
if (a[1]==b[1])
return (a[0]>b[0]?1:-1)(order==“asc”?1:-1);
else
return (a[1]>b[1]?1:-1)
(order==“asc”?1:-1);
} else
return (a[2]>b[2]?1:-1)*(order==“asc”?1:-1);
}

Now it works. Thanks for support.