标签:blog ar java for div log as tt javascript
排序有一种方法,是两个相比,取其中小的,排序,然后跟下一个比,一直比下去;
var arr=[99,89,0,56,4,7,2,4,1,33,22,11]; for(var i=0; i<arr.length; i++){ var iMin=9999999999999999; var iMinIndex=-1; for(var j=i;j<arr.length; j++){ if(arr[j]<iMin){ iMin=arr[j]; iMinIndex=j; } }; var tmp; tmp=arr[i]; arr[i]=arr[iMinIndex]; arr[iMinIndex]=tmp; } alert(arr);
标签:blog ar java for div log as tt javascript
原文地址:http://www.cnblogs.com/wujidns/p/4133622.html