Bug 110718
Summary: | Array.prototype.sort is not quite stable | ||
---|---|---|---|
Product: | WebKit | Reporter: | Richard Gibson <richard.gibson> |
Component: | JavaScriptCore | Assignee: | 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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Kyle Simpson
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
Argh, forgive me for the misplaced report. WebKit handles this just fine; V8 is the inconsistent engine here. Moving discussion to their tracker.