New issue
Advanced search Search tips

Issue 896286 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 758083
Owner: ----
Closed: Oct 17
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

ES5 Sort is not working

Reported by kkaul1...@gmail.com, Oct 17

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36

Steps to reproduce the problem:
1. open console in developer tools
2. create an array with numbers and call sort() on the array. [1,30,4,21]
3. return the sorted array.

What is the expected behavior?
should return var array1 = [1, 4, 21, 30];

What went wrong?
returns [1, 21, 30, 4]

Did this work before? Yes chrome 69

Chrome version: 70.0.3538.67  Channel: stable
OS Version: OS X 10.14.0
Flash Version:
 
Screen Shot 2018-10-17 at 10.25.06 AM.png
117 KB View Download
Sounds like a duplicate of  issue 758083 .
The observed behavior is correct and it never changed.
Chrome always performed a lexicographic sort as required by the JavaScript specification when no comparator function is supplied.
Other browsers also behave this way.

More info: 
* https://tc39.github.io/ecma262/#sec-array.prototype.sort
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
* solutions: https://stackoverflow.com/questions/1063007/how-to-sort-an-array-of-integers-correctly

Mergedinto: 758083
Status: Duplicate (was: Unconfirmed)

Sign in to add a comment