Bug 110718

Summary: Array.prototype.sort is not quite stable
Product: WebKit Reporter: Richard Gibson <richard.gibson>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: getify
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 110007    

Richard Gibson
Reported Monday, February 25, 2013 1:16:53 AM UTC
The results of sorting length-N arrays for sufficiently large N appear to differ from a stable sort only at indices 0, 1, and N/2. It would be very convenient for Sizzle and jQuery if the sort were made fully stable, *especially* if such change lands in 537.32 so there's no release in which #108274 is fixed but this is not. Example with strings: http://jsfiddle.net/zTprj/1/ Example with DOM nodes: http://jsfiddle.net/vU2uB/ jQuery tickets: http://bugs.jquery.com/ticket/13505 http://bugs.jquery.com/ticket/13331
Attachments
Kyle Simpson
Comment 1 Monday, February 25, 2013 1:42:47 AM UTC
For reference, discussion thread for Chrome about this: http://code.google.com/p/v8/issues/detail?id=90 In particular, some people on the thread balk at stabilizing the sort because the spec for JS doesn't mandate stable sort (apparently wanting to give implementers more flexibility for performance sake).
Richard Gibson
Comment 2 Monday, February 25, 2013 2:49:38 AM UTC
Argh, forgive me for the misplaced report. WebKit handles this just fine; V8 is the inconsistent engine here. Moving discussion to their tracker.
Note You need to log in before you can comment on or make changes to this bug.