Quote:
Originally Posted by Airblader
@ rndme
1. True
2. Not entirely -- some sorting algorithms will compare an element to itself. Your sorting function should always support this case (which just using the difference does, of course).
|
what do you mean by "some sorting algorithms"?
im talking about
Code:
function srtStr(a,b){return a>b?1:-1;}
versus
Code:
function srtStr(a,b){return a>b?1:(b==a?0:-1);}
i also said "when sorting unique strings", which means that the difference is always NaN, unless you know something i don't...
after all, if the elements are unique, it's impossible for a proper sort function to return zero.