It could be the other way around. Maybe `Array.prototype.sort` and
`Array.prototype.fastSort`. The former is required to be stable, but the
latter wouldn't.

A polyfill could check if `A.p.sort` is stable, replacing if necessary, and
alias the old one to `A.p.fastSort` if it doesn't exist.

On Thu, Mar 17, 2016, 19:42 Dean Landolt <d...@deanlandolt.com> wrote:

> Why should you have to opt into to stable sort? Why not the other way
> around? `Array.prototype.fastestSort` or some such -- or better yet, spec a
> symbol for it that falls back to `Array.prototype.sort` for implementations
> that don't expose a faster unstable variety.
>
> On Thu, Mar 17, 2016 at 7:35 PM, Isiah Meadows <isiahmead...@gmail.com>
> wrote:
>
>> How about an `Array.prototype.stableSort(comparator?)` method? Several
>> languages already have something like this, anyways.
>>
>> (Speaking of bugs related to unstable sorts, my blog has that problem as
>> well - unstable sort resulting in incorrect order.)
>>
>> On Wed, Mar 16, 2016, 18:50 Tab Atkins Jr. <jackalm...@gmail.com> wrote:
>>
>>> On Tue, Mar 15, 2016 at 8:50 AM, Vic99999 <vic99...@yandex.ru> wrote:
>>> >> What about the Timsort?
>>> >
>>> > I cannot believe it will be faster on random int array. And TimSort is
>>> base on MergeSort and, seems, for it's worst cases it cannot be better than
>>> MergeSort.
>>> > I have tried https://github.com/mziccard/node-timsort/ with my old
>>> node.js - 0.10.4 and Chrome 49 (win32) - and I see that random int array
>>> case is much slower that native in Chrome, and in node.js too if I replace
>>> "native" with a function from
>>> https://github.com/v8/v8/blob/master/src/js/array.js .
>>> >
>>> > Perhaps, implementers will want to leave the behaviour of
>>> `array.sort(comparefn)` as it was for backward compatiblity.
>>>
>>> There's no back-compat impact for switching to a stable sort; since
>>> you can't depend on the ordering of an unstable sort in the first
>>> place, changing that order (to stable) is fine.  (Most likely it'll
>>> *fix* pages that are currently sometimes broken in small ways because
>>> they assume stability.)  It's just potentially a minor speed drop.
>>>
>>> ~TJ
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to