Custom Sort - Return 0


I have a tree grid which is populated with data from an ajax response, I have implemented custom sorting on one of the columns, the idea here is to perform the sort operation only on the rows whose parent is expanded.

I see that the custom sort function is called, but when I force it not to sort (return 0) the grid is still sorted. Has anyone come across this? any solutions?

Unfortunately the problem cannot be reconstructed locally.
Could you please, provide your custom sorting function code so it can be tested.