I have a list to be sorted but it cannot be done if values are represented as strings. Example:
to sort: OB123, OB1212, Maintenance, Daily check, OB123
desired result: Daily check, Maintenance, OB123, OB123, OB1212
if values are strings result is: Daily check, Maintenance, OB1212, OB123,OB123
Therefore I need to use comparator to first sort aircraft numbers such OB123 by their carrier(OB), than by their number (123) and sometimes suffix (""). And after that I would like to compare the whole name with all the rest values as "daily check" etc.
So far I can sort only flight Ids:
@Override
public int compareTo(FlightNumberDisplay toCompare) {
int result = _carrier.compareTo(toCompare.getCarrier());
if (result == 0) {
result = _number.compareTo(toCompare.getNumber());
if (result == 0) {
result = _suffix.compareTo(toCompare.getSuffix());
}
}
return result;
}
So since "Daily check" has also carrier+number+suffix representation it is sorted according to it. The question is how to sort them according to their names.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…