• + 1 comment

    First of all the comparison function does not return true or false, it returns a number, say the function compares x and y, if returns 0 means 2 elements are equal, if greater than 0 means x > y if smaller than 0 means x < y.

    Now back to the function, first , if string x and y both are in same length, then use the comparison function provided by string. if not use length of x minus the length y. That's the result we would want.