New issue
Advanced search Search tips

Issue 779 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 90
Owner: ----
Closed: Jul 2010
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: ----



Sign in to add a comment

javascript Array.sort() bug

Reported by heshunf...@gmail.com, Jul 15 2010

Issue description

try running 
[{sortId:1,title:'a'},{sortId:1,title:'b'},{sortId:1,title:'c'},{sortId:1,title:'d'}].sort(function(a,b){return b.sortId-a.sortId});


in Chrome 5.0.375.99, it gives you [{sortId:1,title:'b'}, {sortId:1,title:'c'}, {sortId:1,title:'a'}]. Huh?

in Firefox 3.0, Safari 3.1 and IE7 it gives you [{sortId:1,title:'a'}, {sortId:1,title:'b'}, {sortId:1,title:'c'}] as 
expected.

i had seen  Issue 103 ,it doesn't work
 

Comment 1 by ager@chromium.org, Jul 15 2010

Mergedinto: 90
Status: Duplicate
This is working as intended. The output is correctly sorted by sortId. If you want to sort by title as well that should be part of the sort function. The issue here is whether or not the sort algorithm is stable. V8 does not use a stable sorting algorithm.

Sign in to add a comment