发现一个很有意思的排序算法,用js重写了一遍:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
var arr = "23,75,42,78,34,16,89,46,53".split(','); var result = ''; for (var i = 0,count = 0; i < arr.length; i++) { var value = arr[i]; (function(value) { setTimeout(function() { result += value + ','; }, value * 10); count = count + value * 10; })(value) } setTimeout(function() { console.log(result.substr(0, result.length - 1)); }, count + 100); |
文章评论 暂无评论
暂无评论