组合排序

        var combSort = function(array){
          var gap = array.length;
          do{
            gap = gap * 10 / 13
            if(gap === 9 || gap === 10)
              gap = 11
            if(gap < 1){
              gap = 1
            }
            var swapped = false;
            for(var i=0;i<array.length-gap;i++){
              var j = i + gap
              if(array[i]>array[j]){
                var temp = array[i];
                array[i] = array[j];
                array[j] = temp;
                test(array)
                swapped = true
              }
            }
            if(gap == 1 && !swapped){
              break;
            }
          }while(1);
        }

你可能感兴趣的:(排序)