FlowComparator.java [src/java/groundwater] Revision: 87d1785a457caf03ed52dccdce3c74db5108caaa Date: Fri Feb 05 09:59:57 MST 2016
package groundwater;
import java.util.Comparator;
/**
* Last Updated: 5-February-2016
* @author Tyler Wible
* @since 4-February-2016
*/
public class FlowComparator implements Comparator<String[]>{
//Compares the second entry of sorted data as flow values and sorts largest to smallest
public int compare(final String[] entry1, final String[] entry2) {
double value1 = 0;
double value2 = 0;
try{
value1 = Double.parseDouble(entry1[1]);
value2 = Double.parseDouble(entry2[1]);
}catch(NumberFormatException e){
e.printStackTrace();
}
if (value1 > value2){
return -1;
}else if (value1 < value2){
return 1;
}else{
return 0;
}
}
}