FlowComparator.java [src/java/m/cfa] Revision: Date:
package m.cfa;
import java.util.Comparator;
/**
* Last Updated: 4-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;
}
}
}