Issue metadata
Sign in to add a comment
|
Incorrect result of works "Array.prototype.sort" function
Reported by
i.prilad...@gmail.com,
Jul 28 2016
|
||||||||||||||||||||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Steps to reproduce the problem:
Code:
var testArray = [];
for(var i=0; i<11; i++){
testArray.push({index:i});
}
console.log(testArray[0].index,
testArray[Math.floor(testArray.length/2)].index);
testArray.sort();
console.log(testArray[0].index,
testArray[Math.floor(testArray.length/2)].index);
Result in Chrome:
0 5
5 1
Result in Firefox:
0 5
0 5
What is the expected behavior?
All array elements are compared as strings "[object Object]". Consequently their location in the array does not change.
What went wrong?
Why swap the elements at indices '1' and 'Math.floor(testArray.length/2)'
Did this work before? No
Chrome version: 51.0.2704.103 Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
,
Aug 10 2016
Better triage label...
,
Aug 10 2016
,
Aug 10 2016
This is working as intended: sort is not guaranteed to be stable (see various historical discussion on issue v8:90 ). |
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by kojii@chromium.org
, Jul 29 2016Labels: -OS-Windows OS-All
Status: Untriaged (was: Unconfirmed)