Skip to content

Commit

Permalink
[Normative] Make %TypedArray%.prototype.sort stable
Browse files Browse the repository at this point in the history
Currently, only 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].

[1] https://bugs.chromium.org/p/v8/issues/detail?id=8567
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1290554
[3] #1340 (comment)
  • Loading branch information
mathiasbynens committed Jan 29, 2019
1 parent 257cae9 commit cd23993
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 cd23993

Please sign in to comment.