private void quickSort(List<Pair> ps, int left, int right) {

		int l_hold, r_hold;

		l_hold = left;
		r_hold = right;
		int pivotidx = left;

		Pair pivot = ps.get(pivotidx);

		while (left < right) {

			while (ps.get(right).getD2() <= pivot.getD2() && left < right) {
				right--;
			}

			if (left != right) {

				ps.set(left, ps.get(right));
				left++;
			}

			while (ps.get(left).getD2() >= pivot.getD2() && left < right) {
				left++;
			}
			
			if (left != right) {

				ps.set(right, ps.get(left));
				right--;
			}
		}

		ps.set(left, pivot);
		pivotidx = left;
		left = l_hold;
		right = r_hold;

		if (left < pivotidx) {
			quickSort(ps, left, pivotidx - 1);
		}
		if (right > pivotidx) {
			quickSort(ps, pivotidx + 1, right);
		}
	}