Skip to content

🐛 Chrome 70 array.sort uses stable TimSort which exposed bunch of bugs#18777

Merged
aghassemi merged 3 commits intoampproject:masterfrom
aghassemi:tests
Oct 17, 2018
Merged

🐛 Chrome 70 array.sort uses stable TimSort which exposed bunch of bugs#18777
aghassemi merged 3 commits intoampproject:masterfrom
aghassemi:tests

Conversation

@aghassemi
Copy link
Copy Markdown
Contributor

Chrome switched to a version of V8 that has implemented a new sorting algorithm (TimSort instead of QuickSort) which is stable. We have had bunch of bad compare functions and had been lucky so far with unstable result matching our expectations but, well lucky streak is over.

See https://twitter.com/mathias/status/1036626116654637057

Additionally the 15px scrollbar is gone in Chrome 70

Back to sort issues:
1- sortInDomOrder in fixed layer was mostly wrong.
2- can't do sort((x, y) => x > y anymore (sure it was wrong in the first place, but... it worked)
3- platform-store.js's sort was unstable.

@aghassemi aghassemi changed the title 🐛 Chrome 70 array.sort usages stable TimSort which exposed bunch of bugs 🐛 Chrome 70 array.sort uses stable TimSort which exposed bunch of bugs Oct 17, 2018
it('custom Array#sort()', () => {
expect(evaluate('[11, 1, 2].sort()')).to.deep.equal([1, 11, 2]);
expect(evaluate('[11, 1, 2].sort((x, y) => x > y)'))
expect(evaluate('[11, 1, 2].sort((x, y) => x - y)'))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice sleuthing!

@aghassemi
Copy link
Copy Markdown
Contributor Author

@jridgewell @dvoytenko I am merging to make master green and unblock PRs, but please do review and I will address comments in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants