public ArrayList<String> union(ArrayList<String> x, ArrayList<String> y) {
		ArrayList<String> answer = new ArrayList<String>();
		Collections.sort(x);
		Collections.sort(y);
		String docId1, docId2;
		boolean isUndermost;
		do {
			docId1 = x.get(0);
			docId2 = y.get(0);
			isUndermost = false;
			if (docId1.compareTo(docId2) < 0) {
				isUndermost = true;
			}

			if (docId1.equals(docId2)) {
				answer.add(docId1);
				x.remove(0);
				y.remove(0);
			} else if (isUndermost) {
				answer.add(docId1);
				x.remove(0);
			} else {
				answer.add(docId2);
				y.remove(0);
			}
		} while (!x.isEmpty() && !y.isEmpty());
		if (x.isEmpty()) {
			for (String s : y) {
				answer.add(s);
			}
		} else if (y.isEmpty()) {
			for (String s : x) {
				answer.add(s);
			}
		}

		return answer;
	}