From bca09ae2d1827db2df77917f62d10e7c8ce36908 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 4 Oct 2022 21:25:54 +0200 Subject: [PATCH] Refactor the sorting of competitors --- app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java b/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java index 84b79f7..852734b 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java @@ -48,7 +48,17 @@ public class Competitor implements Comparable { @Override public int compareTo(Competitor o) { - return Long.compare(parseTime(getTime()), parseTime(o.getTime())); + int result = rank - o.rank; + + if (result == 0) { + result = Long.compare(parseTime(getTime()), parseTime(o.getTime())); + + if (result == 0) { + result = getName().compareTo(o.getName()); + } + } + + return result; } @Override