Add sun/moon emojis to sunrise/sunset and fix direction sorting (direction 1 always on top)
This commit is contained in:
@@ -420,12 +420,21 @@ function groupDeparturesByLineNumber(departures) {
|
||||
groups[lineNumber].directions[directionKey].departures.push(departure);
|
||||
});
|
||||
|
||||
// Convert to array format
|
||||
// Convert to array format and sort directions by direction_code (1 first, then 2)
|
||||
return Object.entries(groups).map(([lineNumber, data]) => {
|
||||
// Sort directions: direction 1 first, then direction 2
|
||||
const directionsArray = Object.values(data.directions);
|
||||
directionsArray.sort((a, b) => {
|
||||
// Sort by direction_code: 1 comes before 2
|
||||
const dirA = a.direction || 1;
|
||||
const dirB = b.direction || 1;
|
||||
return dirA - dirB;
|
||||
});
|
||||
|
||||
return {
|
||||
lineNumber: lineNumber,
|
||||
line: data.line,
|
||||
directions: Object.values(data.directions)
|
||||
directions: directionsArray
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user