public static void sortStoreIncrementsInArray(Comparable[] a)
	{
		// Sort a[] into increasing order.
		int N = a.length;

		Vector<Integer> h = new Vector<Integer>();
		for (int i = 1; i < N / 3; i = 3 * i + 1)
			h.add(i); // 1, 4, 13, 40, 121, 364, 1093, ...

		// h-sort the array.
		for (int k = (h.size() - 1); k >= 0; k--)
		{
			// Insert a[i] among a[i-h], a[i-2*h], a[i-3*h]... .
			for (int i = h.elementAt(k); i < N; i++)
				for (int j = i; j >= h.elementAt(k)
						&& SortHelper.less(a[j], a[j - h.elementAt(k)]); j -= h
						.elementAt(k))
					SortHelper.exch(a, j, j - h.elementAt(k));
		}
	}