用js写的冒泡排序
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>我的冒泡排序</title>
<script>
function test(){
var array=[9,3,1,78,2,6];
for(var i=0;i<array.length;i++){
var temp;
for(var j=0;j<array.length-1-i;j++){
if(array[j]>array[j+1]){
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
alert(array);
}
test();
</script>
</head>
<body>
</body>
</html>