code: @SuppressWarnings("SameParameterValue")
      private static void insertionSort(double[] key, double[][] values, int start, int end, int limit) {
          // loop invariant: all values start ... i-1 are ordered
          for (int i = start + 1; i < end; i++) {
              double v = key[i];
              int m = Math.max(i - limit, start);
              for (int j = i; j >= m; j--) {
                  if (j == m || key[j - 1] <= v) {
                      if (j < i) {
                          System.arraycopy(key, j, key, j + 1, i - j);
                          key[j] = v;
                          for (double[] value : values) {
                              double tmp = value[i];
                              System.arraycopy(value, j, value, j + 1, i - j);
                              value[j] = tmp;
                          }
                      }
                      break;
                  }
              }
          }
      }
docs: Limited range insertion sort.  We assume that no element has to move more than limit steps
  because quick sort has done its thing. This version works on parallel arrays of keys and values.
  
  @param key    The array of keys
  @param values The values we are sorting
  @param start  The starting point of the sort
  @param end    The ending point of the sort
  @param limit  The largest amount of disorder