public long runSortWithCounter(T[] a, int l, int r, long keycount) {
		int H;
		int rt, lt;

		if (l + 1 < r) {
			lt = l - 1;
			rt = r;
			H = a[r].getKey();

			while (lt <= rt) {
				do {
					lt++;
					keycount++;
				} while (a[lt].getKey() < H);

				do {
					rt--;
					keycount++;
				} while (a[rt].getKey() > H);

				Util.switchValues(a, lt, rt);
			}
			Util.switchValues(a, lt, rt);
			Util.switchValues(a, lt, r);
			if (l < rt) {
				keycount = runSortWithCounter(a, l, rt, keycount);
			}
			if (lt + 1 < r) {
				keycount = runSortWithCounter(a, lt + 1, r, keycount);
			}
		} else {
			if (a[l].getKey() > a[r].getKey()) {
				Util.switchValues(a, l, r);
			}
			keycount++;
		}
		return keycount;
	}