MTR: Sort schedules by route

This commit is contained in:
2022-11-15 00:22:39 +08:00
parent a062e37a4c
commit 55d4ac4adc
2 changed files with 25 additions and 1 deletions

View File

@@ -47,3 +47,16 @@ func ( this *BusStop ) Reload() {
this.Key = &this.RouteId
this.SearchData = &searchData
}
type ByRoute [] *BusStop
func (a ByRoute) Len() int { return len(a) }
func (a ByRoute) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRoute) Less(i, j int) bool {
_a := *a[i]
_b := *a[j]
if _a.RouteId == _b.RouteId {
return _a.Direction < _b.Direction
}
return _a.RouteId < _b.RouteId
}