You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method sorts the elements of this array. The sort must be stable (that is, elements that compare equal must remain in their original order). <OMITTED>
In 23.2.3.29 %TypedArray%.prototype.sort ( comparefn ):
This is a distinct method that, except as described below, implements the same requirements as those of Array.prototype.sort as defined in 23.1.3.30. <OMITTED>
While them, it seems there're no references to theses stability from toSroted functions. First introduced in #2997
toSorted is just using SortIndexedProperties. But SortIndexedProperties is also not requiring the stability (to me), so currently it seems it's ok to be not stable.
In 23.1.3.30.1 SortIndexedProperties ( obj, len, SortCompare, holes ), there's the requirements for permutation used for the sort, but it's only requiring that any 2 elements which is strictly ordered, is also ordered in the result.
I'm not sure why stability is just mentioned in Array#sort but not in SortIndexedProperties, but I believe that's why this is just missed when toSorted is introduced.
SortIndexedProperties seems just referenced to by 5:
So one idea I can come up with is just moving the stability requirements to SortIndexedProperties.
eshost Output:
If I have chance to see implementations of engines I want to confirm, but now I could think they may share the implementations of sort and toSorted internally. (not sure)
The text was updated successfully, but these errors were encountered:
Description:
Array#sort is defined as stable in ES2019 (10th).
Stable sort for Array.prototype.sort
Array#toSorted is introduced in ES2023 (14th).
In ES2024 (15th), the statements for stability can be found as follows:
In introduction:
[Normative] Make Array.prototype.sort stable #1340
In 23.1.3.30 Array.prototype.sort ( comparefn ):
[Normative] Make Array.prototype.sort stable #1340
In 23.2.3.29 %TypedArray%.prototype.sort ( comparefn ):
So it is indirectly mentioning the requirements for stability of the sort. It's introduced in [Normative] Make %TypedArray%.prototype.sort stable #1433
While them, it seems there're no references to theses stability from toSroted functions. First introduced in #2997
toSorted is just using SortIndexedProperties. But SortIndexedProperties is also not requiring the stability (to me), so currently it seems it's ok to be not stable.
In 23.1.3.30.1 SortIndexedProperties ( obj, len, SortCompare, holes ), there's the requirements for permutation used for the sort, but it's only requiring that any 2 elements which is strictly ordered, is also ordered in the result.
I'm not sure why stability is just mentioned in Array#sort but not in SortIndexedProperties, but I believe that's why this is just missed when toSorted is introduced.
SortIndexedProperties seems just referenced to by 5:
So one idea I can come up with is just moving the stability requirements to SortIndexedProperties.
eshost Output:
If I have chance to see implementations of engines I want to confirm, but now I could think they may share the implementations of sort and toSorted internally. (not sure)
The text was updated successfully, but these errors were encountered: