In my honest opinion, there's not much reason to just require the sort to
be stable. Some engines have done this in the past, and the spec
technically allows it. At this point, stable sorts are about as fast as
unstable ones, both in theory and practice (wasn't the case 10 years ago
IIRC).

On Thu, Mar 10, 2016, 20:51 kdex <[email protected]> wrote:

> Just some nitpicking from an API point of view:
>
> `Array.prototype.sort(compareFn, isStable = false)`
>
> should probably be something like:
>
> `Array.prototype.sort(compareFn, options = {})`
>
> (Because who knows what extensions will be proposed in the future.)
>
>
> Am 10.03.2016 um 18:59 schrieb 森建:
> > EcmaScript hasn't have the stable sort method yet.
> > http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.sort
> >
> > Sure, we can create stable sort function by using `Array#sort`,
> > by returning the number of index (e.g. `arr.indexOf(arguments[0]) -
> arr.indexOf(arguments[1])`)
> > when it is equal to both arguments value in `comparefn`.
> > But this is inefficient and perplexing.
> >
> > So, I propose below.
> >
> > `Array#stableSort(comparefn)`
> >
> > or
> >
> > `Array#sort(comparefn, isStable = false)`
> >
> >
> > Thanks!
> > _______________________________________________
> > es-discuss mailing list
> > [email protected]
> > https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to