public static Vector<IncrCmp> sortInstrumented(Comparable[] a)
	{
		// Sort a[] into increasing order.

		int N = a.length;
		int h = 1;
		int nIncrements = 0;
		while (h < N / 3)
		{
			h = 3 * h + 1; // 1, 4, 13, 40, 121, 364, 1093, ...
			nIncrements++;
		}

		Vector<IncrCmp> v = new Vector<IncrCmp>(nIncrements);

		// h-sort the array.
		while (h >= 1)
		{
			// Insert a[i] among a[i-h], a[i-2*h], a[i-3*h]... .
			int nCmp = 0;
			for (int i = h; i < N; i++)
				for (int j = i; j >= h && SortHelper.less(a[j], a[j - h]); j -= h, nCmp++)
					SortHelper.exch(a, j, j - h);
			v.add(new IncrCmp(h, nCmp));
			h = h / 3;
		}
		return v;
	}