冒泡排序怎么会没有效果?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function w(arr){
var temp;
var exchange;
for(var i=0;i<arr.length;i++){
exchange=false;
for(var j=arr.length-2;j<=i;j--){
if(arr[j+1]>arr[j]){
temp=arr[j+1];
arr[j+1]=arr[j];
arr[j]=temp;
exchange=true;
}
}
if(!exchange){
break;
}
}
return arr;
function d(){
str=name1.value;
strs=w(str.split(','));
str="";
for(var i=0;i<strs.length;i++){
str+=strs[i]+'';
}
alert(str);
}
}
</script>
</head>
<body>
<center>
冒泡排序:
<input type="text" name="name1"/>
<input type="button"value="点击" onclick="w()"/><span>中间用逗号隔开</span>
</center>
</body>
</html>