Ver código fonte

improve slightly the ride sort

Gildas Chabot 7 anos atrás
pai
commit
26d82b0895
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1 1
      main.go

+ 1 - 1
main.go

@@ -60,7 +60,7 @@ type ByEndtime []*Ride
60 60
 func (rs ByEndtime) Len() int      { return len(rs) }
61 61
 func (rs ByEndtime) Swap(i, j int) { rs[i], rs[j] = rs[j], rs[i] }
62 62
 func (rs ByEndtime) Less(i, j int) bool {
63
-	return rs[i].f < rs[j].f
63
+	return rs[i].f < rs[j].f || (rs[i].f == rs[j].f && rs[i].length() < rs[j].length())
64 64
 }
65 65
 
66 66
 type Scheduler interface {