Although not technically a spec violation, stable sort was one of the oldest and most popular developer requests in our @v8js bug tracker (issue #90!): https://bugs.chromium.org/p/v8/issues/detail?id=90 …
Kudos to @nimODota for making it happen!
-
-
Show this thread
-
Fingers crossed
@ChakraCore eventually switches to a stable sorting algorithm, too. Then we could update the Array.prototype.sort spec to require stability and call it a day. One can dream… (@ChakraCore’s sort is currently only stable for arrays with 512 or fewer elements.)Show this thread -
Update:
@ChakraCore just landed a stable MergeSort, making its Array.prototype.sort stable — even for arrays with more than 512 elements! https://github.com/Microsoft/ChakraCore/commit/c565b12f0aada9fc188cea5eb5243699d27c56e6 … When this ships in Edge, Array.prototype.sort is finally 100% stable in all browsers!
Show this thread
End of conversation
New conversation -
-
-
How can one detect if sort is stable?
-
It’s not possible to fully “prove” it with a test, but you can observe it with code like the one in my tweet. Here are the Test262 tests I wrote:https://github.com/tc39/test262/pull/1977 …
- 4 more replies
New conversation -
-
-
This gonna break some apps, right?
-
I doubt it. Which apps rely on sort being unstable?
- 5 more replies
New conversation -
-
-
Lots of badly written sort functions will start breaking now. A common one is `[3,1,2].sort( (a, b) => a > b );` Oh well, now is as good as any time to make this change I guess.
-
What do you mean by “breaking”? Inconsistent comparison functions can result in an arbitrary order for “equal” elements, with or without this change.
- 2 more replies
New conversation -
-
-
Indeed. Expect a
@v8js blog post with more details soon! - 3 more replies
New conversation
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.