睡眠排序

睡眠排序

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script>
function sleepsort(){
var arr = [];
console.log(arguments);
for(var i = 0 ,il = arguments.length; i < il;i++){
(function(args,index){
setTimeout(function(){
document.getElementById("result").innerHTML += args[index] + ',';
arr.push(args[index]);
console.log(arr);
},args[index]);
}(arguments,i))
}
}
sleeepsort(5,3,3,1,12,2,6,7,8);
</script>