var objCxMsg=[{'startDay':startDay,'endDay':endDay,'dantian':dantian,'zhekou':zhekou},{'startDay':startDay,'endDay':endDay,'dantian':dantian,'zhekou':zhekou}];
objCxMsg.bubbleSort(function(x,y){return x>y;});

/*冒泡算法*/
Array.prototype.swap=function(i,j){
    var temp=this[i];
    this[i]=this[j];
    this[j]=temp;
}
Array.prototype.bubbleSort=function(comp){
    var l=this.length;
    for(var j=l-1;j>0;j--){
       for(var i=0;i<j;i++){
        if(comp(this[i].startDay,this[i+1].startDay)){
         this.swap(i,i+1);
        }
       }
    }
}

 posted on 2011-01-07 16:46  刘卿  阅读(146)  评论(0编辑  收藏  举报