-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: toSorted methods must be stable #3424
Conversation
I've added another commit fixing a closely related issue, which is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. WDYT about removing the "sort must be stable" sentence in the description of Array.prototype.sort, now that it's pushed to this AO and shared by all callers?
SGTM, done. |
Thanks! Sorry I missed this in the original. |
341d641
to
6de33c0
Compare
ac511f4 is the commit that will fix the IPR check that I included in this PR; I'm going to merge past that one failure to fix main. |
Fixes #3422. Also fixes a closely related issue where
toSorted
was incorrectly not permitted to have implementation-defined order using the default comparator whenToString
is inconsistent.The stability requirements of
Array.prototype.sort
andTypedArray.prototype.sort
are documented only in the introductory paragraphs of those sections. The actual sorting, and its detailed requirements except for stability, are inSortIndexedProperties
.When the
toSorted
methods were introduced toArray
andTypedArray
they referenced onlySortIndexedProperties
, thus implicitly (and accidentally) omitting the stability requirement. This PR spells out the stability requirement more formally inSortIndexedProperties
, which means it is enforced ontoSorted
as well.