Array#sort() implementations not interoperable

Kevin Gadd kevin.gadd at
Thu Jun 13 07:01:47 PDT 2013

Even if stable sorts don't get required, it would make sense to require
that a given implementation is either always stable or always not stable.
The current situation with V8 seems likely to result in subtly broken
software shipping to the web, where it works in testing environments with
small amounts of data and then breaks in the wild only on certain browsers
and only if you have a certain amount of data. Yuck.


On Thu, Jun 13, 2013 at 6:05 AM, Mathias Bynens <mathias at> wrote:

> Bumping this old thread since V8 issue #90 (
> has been getting lots
> of comments lately.
> It appears that unstable sort, while perfectly spec-compliant, doesn’t
> match user expectations. It doesn’t help that some browsers/engines _do_
> use a stable sorting algorithm, while others don’t — which surprises people
> and occasionally breaks (badly-written, but hey) code. (See the thread I
> linked to for examples.) Then, there’s V8, which uses stable sort for small
> arrays with 10 or fewer elements, but an unstable sorting algorithm for
> larger arrays, causing even more confusion.
> Here’s a test case that tests arrays of varying sizes:
> The results in different
> browsers are listed, too.
> IMHO it would be nice if ES would require a stable sorting algorithm: it
> would match user expectations, cause fewer issues in existing code, and
> improve operability in general.
> What would be the best way to make TC39 consider this change?
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list