title: Bubble Sort to gap sort modification
body: <p>I've run in to a problem and need your guidance. Basically i managed to create this Bubble Sort method. How can i modify this to Gap Sort, that rather than comparing neighboring elements each time through the list, compares elements that are some number(i) positions apart, where (i) is an integer less than n. For example, the first element would be compared to the (i + 1) element, 2nd element to the (i + 2) element, nth element to the (n-i) element, etc. A single iteration is completed when all of the elements that can be compared, have been compared. On the next iteration, i is reduced by some number greater than 1 and the process continues until i is less than 1</p>
  
  <pre><code>public static void bubbleSort (Comparable[] data, int maxlength){
      int position, scan;
      Comparable temp;
  
      for (position = maxlength; position &gt;= 1; position--){
          for (scan = 0; scan &lt;= position – 1; scan++){
              if (data[scan].compareTo(data[scan+1]) &gt; 0){
                  // Swap the values
                  temp = data[scan];
                  data[scan] = data[scan + 1];
                  data[scan + 1] = temp;
              }
          }
      }
  }
  </code></pre>