style: use compareValuesBy in SDProblem Comparable implementation

This commit is contained in:
Johannes Frohnmeyer 2024-06-09 10:03:14 +02:00
parent 0353c672fc
commit 0856a4dcce
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -10,8 +10,6 @@ data class SDProblem(val id: String, val name: String, val rgb: Color, var solve
}
override fun compareTo(other: SDProblem): Int {
return solved.compareTo(other.solved)
.run { if (this == 0) rgb.rgb.compareTo(other.rgb.rgb) else this }
.run { if (this == 0) name.compareTo(other.name) else this }
return compareValuesBy(this, other, SDProblem::solved, { it.rgb.rgb }, SDProblem::name)
}
}