How does sort function work in javascript, along with compare function
<p>As already asked, how does sort function work in javascript, along with compare function?
If I have an array, and I do array.sort(compare) now it was written in the book that if the compare function returns a-b(two indices of the array) then it works based on the fact that whether the result is greater than 0, less than 0 or equal to 0. But how exactly does it work? I could not work it out.</p>
