[英]Fast sorting with JavaScript built-in functions
Some time ago, I asked a question on Stack Overflow about sorting an array with JavaScript
reduce
function.前段时间在Stack Overflow上问了一个关于用
JavaScript
reduce
函数对数组进行排序的问题。 And many kind users answer my question and I got some ideas about implementing a sorting algorithm with reduce
function.许多好心的用户回答了我的问题,我对使用
reduce
函数实现排序算法有了一些想法。
Actually, In my newest project, I have a big array that should be sort as fast as could happen ever.实际上,在我最新的项目中,我有一个大数组,应该尽可能快地排序。 I implement some algorithms but I think I do not use
JavaScript
functions truly.我实现了一些算法,但我认为我并没有真正使用
JavaScript
函数。 I read some articles in medium and one of them is this article .我读了一些中等的文章,其中一篇就是这篇文章。 I don't seek for a high-performance algorithm for sorting.
我不寻求高性能的排序算法。 Just like the article said, there is no fast way faster than nLog(n) .
正如文章所说,没有比nLog(n)更快的方法了。 I seek a real fast implementation in execution.
我寻求真正快速的执行。
Is there a JavaScript
built-in function for this or do you know an awesome sorting implementation for sorting big scale arrays?是否有用于此的
JavaScript
内置函数,或者您是否知道用于排序大型数组的出色排序实现?
const array1 = [1, 30, 4, 21, 100000];
array1.sort();
array1.sort(function sortFunction() {...})
More info:更多信息:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.