标签:cti style bsp length class bubble log code span
<script type="text/javascript"> function bubbleSort(ary) { for(var i =0;i<ary.length-1;i++){ var flag = false; for(var j = 0;j<ary.length-1-i;j++){ if(ary[j]>ary[j+1]){ ary[j]=ary[j]+ary[j+1]; ary[j+1]=ary[j]-ary[j+1]; ary[j] =ary[j]-ary[j+1]; flag = true; } } if(flag){ flag =false; }else { break; } } return ary; } var arr=[2,51,3,1,7,8,78,89]; console.log(bubbleSort(arr)); </script>
标签:cti style bsp length class bubble log code span
原文地址:http://www.cnblogs.com/zzzzzzzsy/p/6573007.html