javaCollections排序--多条件排序
java Collections 排序–多条件排序
// 告警排序
Collections.sort(domesticAirport, comparator);
// 告警排序
茄子卷Comparator<AirportRtWeatherWarningBeanForTable> comparator = new Comparator<AirportRtWeatherWarningBeanForTable>() { @Override
public int compare(AirportRtWeatherWarningBeanForTable a1, AirportRtWeatherWarningBeanForTable a2) {
// ⾸先根据是否过期排序
if(a1.isMetarExpired() && !a2.isMetarExpired()){荔枝的作用
return1;
辩论赛流程}el if (!a1.isMetarExpired() && a2.isMetarExpired()) {
return -1;
} el if ((a1.isMetarExpired() && a2.isMetarExpired()) || (!a1.isMetarExpired() && !a2.isMetarExpired())) {
//同时过期,或者都不过期,则按告警类型排序
if (a1.getWarningColor() != a2.getWarningColor()) {
return WarningColor(), a2.getWarningColor());
}
}
//告警类型相同,按字母排序
Code4().Code4());
}
};
// 告警类型⽐较排序
public int compareColor(Color color1, Color color2) {
int i = 0;
int j = 0;
if (color1.equals(MeteoWeatherWarningPanel.RED)) {
i = 3;
} el if (color1.equals(MeteoWeatherWarningPanel.YELLOW)) {东莞英语
i = 2;
室内足球} el if (color1.equals(MeteoWeatherWarningPanel.GREEN)) {
梦见初恋情人i = 1;
}
if (color2.equals(MeteoWeatherWarningPanel.RED)) {
j = 3;
} el if (color2.equals(MeteoWeatherWarningPanel.YELLOW)) {
豆浆机什么牌子的好j = 2;
} el if (color2.equals(MeteoWeatherWarningPanel.GREEN)) {
j = 1;
}
int k = i - j;
if (k > 0) {
return -1;
} el if (k < 0) {
return1;
} el
异言return0;
}