-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Array.prototype.sort
stable
#1494
Conversation
Ah hah -- I figured out how this used to fail. There is a test called "ComparatorTest" that tests with a comparator that returns a random number -- other JavaScript engines could run this test without error, but Java throws an exception SOMETIMES. We got lucky on this CI run but it still happens. Here's the stack trace: ava.lang.IllegalArgumentException: Comparison method violates its general contract! I suppose that we COULD just catch this exception and leave the array unsorted at this point, since once the comparator is behaving in a terrible way there's not much else we could do -- I would support that if it made sense. |
Agreed, if that makes us more spec-compliant and doesn't break anything we already have, I'd say go for it! |
Okay, the implementation now performs a |
Looks good -- you just need to run "./gradlew spotlessApply", and unfortunately that has to be run on Java 11 because that tool doesn't work on multiple Java versions for us. Thanks! |
I created a new PR, #1526, which contains these commits plus a fix to spotless so that it builds. |
This change removes the
Sorting
class and its corresponding test, and just usesArrays.sort
to get a stable sort.Fixes #1151.