Javascript 排序列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5218485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript sorted lists
提问by eshalev
Is there a sorted list in Javascript or jQuery?
Javascript 或 jQuery 中是否有排序列表?
I have a huge list with few insert actions over time. I cannot afford to call object.sort() for the entire list each time I add a single item. I need an insert of o(log(n));
我有一个很大的列表,随着时间的推移几乎没有插入操作。每次添加单个项目时,我都无法为整个列表调用 object.sort()。我需要插入 o(log(n));
采纳答案by eshalev
Found this: Haven't used it yet, but looks good.
发现这个:还没有使用它,但看起来不错。
回答by T.J. Crowder
No, there isn't, all you have is Array#sortwhich you've ruled out using repeatedly (and with good reason!). You'll have to use an insertion sortapproach.
不,没有,你所拥有的只是Array#sort你已经排除重复使用的东西(并且有充分的理由!)。您将不得不使用插入排序方法。

