Skip to content

Commit b5016c4

Browse files
committed
fix(frequencies): sort trips with frequencies by Frequency#startTime values
fixes #191
1 parent cb5a7f8 commit b5016c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/editor/util/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export function sortAndFilterTrips (
5454
// Sort by first arrival time. If they are the same, fall back on first
5555
// departure time. Finally, sort by trip ID.
5656
.sort((a, b) => {
57+
if (a.frequencies.length > 0 && b.frequencies.length > 0) {
58+
// Sort frequency trips purely by start time. (Stop times are all
59+
// the same for frequencies of the same pattern.) Generally, a trip
60+
// only has one frequency entry (for now).
61+
return a.frequencies[0].startTime - b.frequencies[0].startTime
62+
}
5763
// There may be a case where a null value (skipped stop) appears first
5864
// in the list of stopTimes. In this case, we want to compare on the
5965
// first stopTime that exists for each pair of trips.

0 commit comments

Comments
 (0)