I have two class
public class PopularSports {
public int Rank;
public String Sport;
}
public class Medals {
public String Sport
public String Medal
public int Year
public String Game
public String Athlete
}
When i try to lead their csv and get the result in List of each class, I want to sort them in following order.
The PopularSports class should sort in the following order:
- Rank
- Sport
The Medals class should sort in the following order:
- Sport
- Medal
- Year
- Game
- Athlete
I have created compactor like this
Collections.sort(medalReportList, new Comparator<Medals >() {
@Override
public int compare(Medals o1, Medals o2) {
return getRankOfSportBySportName(o1.getSport()) > getRankOfSportBySportName(o2.getSport())
? +1
: getRankOfSportBySportName(o1.getSport()) < getRankOfSportBySportName(o2.getSport())
? -1
: o1.getAthlete().compareToIgnoreCase(o2.getAthlete());
}
});
But it is not making it happen, it sorts on athlete names.
getRankOfSportBySportNamereturn? Are you sure it works correctly?