Skip to content

Commit

Permalink
[Normative] Make %TypedArray%.prototype.sort stable (#1433)
Browse files Browse the repository at this point in the history
Currently V8 [1] and SpiderMonkey [2] have unstable
`%TypedArray%.prototype.sort` implementations. Both teams have
publicly committed to making their implementations stable, to
match `Array.prototype.sort` [3].

Test262 tests: tc39/test262#2062
  • Loading branch information
mathiasbynens authored and ljharb committed Feb 6, 2019
1 parent 2ac02e1 commit a561c88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -33260,7 +33260,7 @@ <h1>%TypedArray%.prototype.some ( _callbackfn_ [ , _thisArg_ ] )</h1>

<emu-clause id="sec-%typedarray%.prototype.sort">
<h1>%TypedArray%.prototype.sort ( _comparefn_ )</h1>
<p>%TypedArray%`.prototype.sort` is a distinct function that, except as described below, implements the same requirements as those of `Array.prototype.sort` as defined in <emu-xref href="#sec-array.prototype.sort"></emu-xref>. Unlike `Array.prototype.sort`, %TypedArray%`.prototype.sort` is not necessarily stable (that is, elements that compare equal do not necessarily remain in their original order). The implementation of the %TypedArray%`.prototype.sort` specification may be optimized with the knowledge that the *this* value is an object that has a fixed length and whose <emu-xref href="#integer-index">integer-indexed</emu-xref> properties are not sparse. The only internal methods of the *this* object that the algorithm may call are [[Get]] and [[Set]].</p>
<p>%TypedArray%`.prototype.sort` is a distinct function that, except as described below, implements the same requirements as those of `Array.prototype.sort` as defined in <emu-xref href="#sec-array.prototype.sort"></emu-xref>. The implementation of the %TypedArray%`.prototype.sort` specification may be optimized with the knowledge that the *this* value is an object that has a fixed length and whose <emu-xref href="#integer-index">integer-indexed</emu-xref> properties are not sparse. The only internal methods of the *this* object that the algorithm may call are [[Get]] and [[Set]].</p>
<p>This function is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.</p>
<p>Upon entry, the following steps are performed to initialize evaluation of the `sort` function. These steps are used instead of the entry steps in <emu-xref href="#sec-array.prototype.sort"></emu-xref>:</p>
<emu-alg>
Expand Down

0 comments on commit a561c88

Please sign in to comment.