Proposal: Static sort method on Array

Isiah Meadows isiahmeadows at
Sun Apr 8 02:55:49 UTC 2018

When I need a non-in-place sort, I just do `array.slice().sort()`.
It's pretty easy, and it still chains. (In my experience, it's rarely
necessary considering most chaining methods like `.map` and `.filter`
already return new instances.)

Isiah Meadows
me at

Looking for web consulting? Or a new website?
Send me an email and we can get started.

On Sat, Apr 7, 2018 at 6:18 PM, T.J. Crowder
<tj.crowder at> wrote:
> On Sat, Apr 7, 2018 at 8:59 PM, Rob Ede <robjtede at> wrote:
>> ...I'm considering creating a proposal to add an Array.sort()
>> method that takes an array and returns a new array...
> That would be:
> ```js
> let newArray = originalArray.slice().sort();
> // or
> let newArray = Array.from(originalArray).sort();
> // or
> let newArray = [...originalArray].sort();
> ```
> I don't know that we need a new static for it. Unless the motivation is to
> allow insertion sort or other sort algorithms that work best when creating a
> new array as a result? But if we assume `Array.prototype.sort` already uses
> quicksort or mergesort or similar, I'm not seeing much reason to add a new
> static to allow insertsion sort or similar...
> Can you expand on use cases and why the above aren't sufficient?
> -- T.J. Crowder
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list