@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void staticMerge(List<String> files, JZSequenceFile file, Comparator comparator) {
		
		final Comparator tempComparator = comparator;

		/* Input files */
		List<JZSequenceFile> inFiles = 
				new ArrayList<JZSequenceFile>();
		
		/* Create the queue used to find the least key */
		Comparator<Object[]> com = new Comparator<Object[]>() {
			@Override
			public int compare(Object[] o1, Object[] o2) {
				return tempComparator.compare(o1[0], o2[0]);
			}
		};	
		PriorityQueue<Object[]> keyQueue = new PriorityQueue<Object[]>(1, com);

		/* Initialize the queue */
		for (int i = 0; i < files.size(); i++) {
			JZSequenceFile infile = 
					new JZSequenceFile(JZFile.JZFileSystem, files.get(i), 0, 0);
			inFiles.add(infile);
			JZSequenceFile.Reader<Object, List<Object>> reader = 
					new JZSequenceFile.Reader<Object, List<Object>>(infile);
			if (reader.nextKeyValue()) {
				Object[] entry = new Object[]{reader.getCurrentKey(), reader};
				keyQueue.offer(entry);
			}
		}

		/* Output file writers */
		JZSequenceFile.Writer<Object, List<Object>> writer = 
				new JZSequenceFile.Writer<Object, List<Object>>(file);

		/* Get the first least key */
		List<Object> list = new ArrayList<Object>();
		Object[] firstEntry = keyQueue.peek();
		Object preKey = (Object) firstEntry[0];
		JZSequenceFile.Reader<Object, List<Object>> reader = 
				(JZSequenceFile.Reader<Object, List<Object>>) firstEntry[1];

		/* Traverse all the sorted block files to get the lists for all keys and sort them */
		while (!keyQueue.isEmpty()) {
			/* Get the least key and corresponding value */
			Object[] entry = keyQueue.poll();
			Object key = (Object) entry[0];
			reader = (JZSequenceFile.Reader<Object, List<Object>>) entry[1];
			List<Object> value = (List<Object>) reader.getCurrentValue();

			/* Add to the list or create a new list */
			if (preKey.equals(key)) {
				list.addAll(value);
			}
			else {
				writer.write(preKey, list);

				//test
				System.out.print("\n" + preKey + ":");
				for (int i = 0; i < list.size(); i++) {
					System.out.print(" " + list.get(i));
				}
				
				preKey = key;
				list = new ArrayList<Object>(value);
			}

			/* Read a new value from the corresponding block where the previous value is read */
			if (reader.nextKeyValue()) {
				Object newKey = (Object) reader.getCurrentKey();
				entry[0] = newKey;
				keyQueue.offer(entry);
			}
			else {
				reader.close();
			}
		}
		
		if (!list.isEmpty()) {
			writer.write(preKey, list);
			
			//test
			System.out.print(preKey + ":");
			for (int i = 0; i < list.size(); i++) {
				System.out.print(" " + list.get(i));
			}
			System.out.println("\n");
		}

		/* Close the writers */
		writer.close();
	}