Skip to content

Commit

Permalink
fix(frequencies): sort trips with frequencies by Frequency#startTime …
Browse files Browse the repository at this point in the history
…values

fixes #191
  • Loading branch information
landonreed committed Nov 16, 2018
1 parent cb5a7f8 commit b5016c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/editor/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export function sortAndFilterTrips (
// Sort by first arrival time. If they are the same, fall back on first
// departure time. Finally, sort by trip ID.
.sort((a, b) => {
if (a.frequencies.length > 0 && b.frequencies.length > 0) {
// Sort frequency trips purely by start time. (Stop times are all
// the same for frequencies of the same pattern.) Generally, a trip
// only has one frequency entry (for now).
return a.frequencies[0].startTime - b.frequencies[0].startTime
}
// There may be a case where a null value (skipped stop) appears first
// in the list of stopTimes. In this case, we want to compare on the
// first stopTime that exists for each pair of trips.
Expand Down

0 comments on commit b5016c4

Please sign in to comment.