Sorted arrays

Axel Rauschmayer axel at rauschma.de
Fri Dec 30 06:57:11 PST 2011


That sounds like you’d want a different data structure: a sorted set. Or a sorted multi-set.

I’d rather write a new constructor than extend Array. You’d also be able to search for elements faster (binary search).

On Dec 30, 2011, at 15:46 , Xavier MONTILLET wrote:

> Hi,
> 
> I think it would be useful to have sort store somewhere in the array
> how it was sorted if it was and a new method append that would insert
> an item so that the array is still sorted.
> 
> Here's how it could be implemented in ES 5 (you would use
> Object.defineProperty to make methods non enumerable):
> http://jsfiddle.net/xavierm02/exwtg/
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111230/ede60217/attachment.html>


More information about the es-discuss mailing list