Tag Archives: JScript

Internet Explorer Array.sort Unreliable

What would you expect to be the result of executing the following code? // Create a medium size array, at least 100 items var obj = []; for(var j=0, k=150; j<k; j++) { // the value here doesn't matter. obj.push('ABCD'+j); }   // Sort the array alphabetically. obj.sort(function(m,p){ m=(''+m).toLowerCase(); p=(''+p).toLowerCase();   if(m > p) return [...]
Posted in JavaScript | Also tagged |