import java.io.File;
import java.util.Comparator;

/**
 * CS400 3DMotionCapture
 * FileComparator
 * 
 * Compares two jpg files that are extracted from some video format
 * The files must start with some numerical name followed by .jpg
 * @author Kohei Shinkawa
 * @version 3-11-2010
 * */

public class FileComparator implements Comparator<File> {

	public int compare(File o1, File o2) {
		String name1 = o1.getName();
		String name2 = o2.getName();
		String[] temp1 = name1.split("\\.");
		String[] temp2 = name2.split("\\.");
				
		if(Integer.parseInt(temp1[0]) > Integer.parseInt(temp2[0])) return 1;
		else if(Integer.parseInt(temp1[0]) < Integer.parseInt(temp2[0])) return -1;
		else{
			if(Integer.parseInt(temp1[1]) > Integer.parseInt(temp2[1])) return 1;
			else if(Integer.parseInt(temp1[1]) < Integer.parseInt(temp2[1])) return -1;
			
		}
		return 0;
	}

}
