public static void sortByGoodness(List<SimilarCluster> values) {
Collections.sort(values, new Comparator<SimilarCluster>() {
public int compare(SimilarCluster f1, SimilarCluster f2) {
int result = 0;
if( f1.getGoodness() < f2.getGoodness() ) {
result = 1; // order in the decreasing order of goodness value
}
else if( f1.getGoodness() > f2.getGoodness() ) {
result = -1;
}
else {
result = 0;
}
return result;
}
});
}
转载于:https://www.cnblogs.com/paulbai/archive/2012/03/25/2417041.html