static void dutch_flag_partition(List<Integer> A, int pivot_index) {
		int pivot = A.get(pivot_index);

		/**
		 * Keep the following invariants during partitioning: 
		 * bottom group: A.subList(0, smaller - 1). 
		 * middle group: A.subList(smaller, equal - 1).
		 * unclassified group: A.subList(equal, larger). 
		 * top group: A.subList(larger + 1, A.size() - 1).
		 */
		int smaller = 0, 
			equal = 0, 
			larger = A.size() - 1;

		// When there is any unclassified element.
		while (equal <= larger) {
			// A.get(equal) is the incoming unclassified element.
			if (A.get(equal) < pivot) {
				swap(A, smaller++, equal++);
			} else if (A.get(equal) == pivot) {
				++equal;
			} else { // A.get(equal) > pivot.
				swap(A, equal, larger--);
			}
		}
	}