Array#sort() implementations not interoperable

Andreas Rossberg rossberg at
Fri Jun 14 00:52:24 PDT 2013

On 14 June 2013 01:42, Kevin Gadd <kevin.gadd at> wrote:
> I'll state it again since I guess maybe the third time is the charm:
> When I said 'always stable' or 'always unstable' i was referring to which
> implementation the browser uses, not what the sort actually does. There's
> nothing beneficial about the fact that an unstable sort happens to rearrange
> elements. My point is that explicitly forbidding Array.sort from
> conditionally switching between sort implementations (or at least from
> switching between implementations with observable differences) is beneficial
> to users. Let's not be ridiculous here.

Try to define "switch algorithm" then. Many real-world implementations
shift their strategy at some size, e.g. a trivial example is doing a
bubble sort at size 3. This is _part_ of the algorithm, really.

Moreover, the spec cannot mandate anything whose properties can
neither be specified nor tested -- how sort works internally is an
implementation detail.

That said, I'd be fine with prescribing stable sort. It's just that
requiring "unstable" is not meaningful.


More information about the es-discuss mailing list