<!DOCTYPE html>
<html>
<head>
<title>24</title>
<meta charset="utf-8">
<script type="text/javascript">
window.onload=function(){
// var list1=new Array(456,789,1,7,9,3333,888,3,12,8);
var list1=new Array();
for(var j=0;j<10000;j++){
list1[j]=Math.floor(Math.random()*(10000-1)+1);
}
var s=new Date();
document.write(kspx(list1));
var e=new Date();
console.log(e-s);
}
function kspx(list){
if(list.length<=1){
return list;
}
var jidindex=Math.floor(list.length/2);
var jid=list.splice(jidindex,1)[0];
var left=[];
var right=[];
for(var i=0;i<list.length;i++){
if(list[i]<jid){
left.push(list[i]);
}else{
right.push(list[i]);
}
}
return kspx(left).concat([jid],kspx(right));
}
</script>
</head>
<body>
</body>
</html>
|