Skip to content
Snippets Groups Projects
Commit 00c6112a authored by Niklas Schrötler's avatar Niklas Schrötler
Browse files

FahrplanPanel: Fixed sorting when first stops are at the same time

parent e0698267
No related branches found
No related tags found
No related merge requests found
......@@ -88,7 +88,18 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => {
}
// Sort the output
newRoutes = newRoutes.sort((a, b) => a.countdown - b.countdown)
newRoutes = newRoutes.sort((a, b) => {
const diff = a.stops[0].arrival.getTime() - b.stops[0].arrival.getTime();
if(diff !== 0) {
return diff;
}
const latestA = Math.max(...a.stops.map(s => s.arrival.getTime()));
const latestB = Math.max(...b.stops.map(s => s.arrival.getTime()));
return latestA - latestB;
})
// Write to the display
setRoutes(newRoutes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment