Proposal: Static sort method on Array
tj.crowder at farsightsoftware.com
Sat Apr 7 22:18:26 UTC 2018
On Sat, Apr 7, 2018 at 8:59 PM, Rob Ede <robjtede at icloud.com> 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:
let newArray = originalArray.slice().sort();
let newArray = Array.from(originalArray).sort();
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss