Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/util/RouteSorterByArrivalTime.kt
Show All 14 Lines | override fun compare(route1: Route?, route2: Route?): Int { | ||||
val passaggi2 = route2.passaggi | val passaggi2 = route2.passaggi | ||||
// handle the case of midnight | // handle the case of midnight | ||||
if (passaggi1 == null || passaggi1.size == 0){ | if (passaggi1 == null || passaggi1.size == 0){ | ||||
if (passaggi2 == null || passaggi2.size == 0) return 0 | if (passaggi2 == null || passaggi2.size == 0) return 0 | ||||
else return 2 | else return 2 | ||||
} else if (passaggi2 == null || passaggi2.size == 0){ | } else if (passaggi2 == null || passaggi2.size == 0){ | ||||
return -2 | return -2 | ||||
} | } | ||||
passaggi1.sort() | //passaggi1.sort() | ||||
passaggi2.sort() | //passaggi2.sort() | ||||
return passaggi1[0].compareTo(passaggi2[0]) | return passaggi1[0].compareTo(passaggi2[0]) | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register