Implement a comparator for sorting names alphabetically
This commit is contained in:
parent
72b926a0a8
commit
73374ed7bb
1 changed files with 12 additions and 3 deletions
|
@ -24,6 +24,10 @@ public class Competitor implements Comparable<Competitor> {
|
|||
return time;
|
||||
}
|
||||
|
||||
public Long getTimeValue() {
|
||||
return parseTime(getTime());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -83,8 +87,13 @@ class AlphaComparatorCompetitor implements Comparator<Competitor> {
|
|||
|
||||
@Override
|
||||
public int compare(Competitor o1, Competitor o2) {
|
||||
// TODO Implement
|
||||
int c = 0;
|
||||
return c;
|
||||
int result = o1.getName().compareTo(o2.getName());
|
||||
|
||||
if (result == 0) {
|
||||
return Long.compare(o1.getTimeValue(), o2.getTimeValue());
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue