当前位置: 代码迷 >> Web前端 >> 一个与此同时满足三组数组排序的冒泡函数
  详细解决方案

一个与此同时满足三组数组排序的冒泡函数

热度:127   发布时间:2012-11-22 00:16:41.0
一个同时满足三组数组排序的冒泡函数
var items_rty = new Array();
var items_star = new Array();
var items_hl = new Array();
for(var r = 0; r<items_rty.length;r++){
 for(var rr=0; rr<items_rty.length;rr++){
	one = items_rty[rr];
	one_s = items_star[rr];
	one_h = items_hl[rr];
	o = complexArray[rr];
	two = items_rty[rr+1];
	two_s = items_star[rr+1];
	two_h = items_hl[rr+1];
	t = complexArray[rr+1];
	if(one < two){
	  items_rty[rr] = two;
	   items_star[rr] = two_s;
	   items_hl[rr] = two_h;
	   complexArray[rr] = t;
	   items_rty[rr+1] = one;
	   items_star[rr+1] = one_s;
	   items_hl[rr+1] = one_h;
	   complexArray[rr+1] = o; 
	}else if(one==two){
	    if(one_s<two_s){
	      items_star[rr] = two_s;
	       items_hl[rr] = two_h;
		complexArray[rr] = t;
	      items_star[rr+1] = one_s;
	      items_hl[rr+1] = one_h;
	      complexArray[rr+1] = o;		  
	  }else if(one_s == two_s){
	       if(one_h < two_h){
	      items_hl[rr] = two_h;
	      complexArray[rr] = t;
	     items_hl[rr+1] = one_h;
		complexArray[rr+1] = o;  
	 }
	}
       }
     }
   }