Sort legs by time
This commit is contained in:
@@ -63,6 +63,36 @@ export function drawDraftingBoard() {
|
|||||||
return leg;
|
return leg;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
display_legs = display_legs.toSorted((leg_a, leg_b) => {
|
||||||
|
if (leg_a.origin_location_id == leg_b.origin_location_id) {
|
||||||
|
if (leg_a.origin_location.departure > leg_b.origin_location.departure) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (leg_a.destination_location_id == leg_b.destination_location_id) {
|
||||||
|
if (leg_a.destination_location.arrival > leg_b.destination_location.arrival) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (leg_a.destination_location_id == leg_b.origin_location_id) {
|
||||||
|
if (leg_a.destination_location.arrival > leg_b.origin_location.departure) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (leg_a.origin_location_id == leg_b.destination_location_id) {
|
||||||
|
if (leg_a.origin_location.departure > leg_b.destination_location.arrival) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let rows = display_legs.length;
|
let rows = display_legs.length;
|
||||||
|
|
||||||
element_board.style.setProperty("--drafting-board-number-locations", display_locations.length);
|
element_board.style.setProperty("--drafting-board-number-locations", display_locations.length);
|
||||||
@@ -161,6 +191,9 @@ export function getLocationWithLeastInboundTrips(locations, legs) {
|
|||||||
let n_a = numberOfInboundLegs(location_a);
|
let n_a = numberOfInboundLegs(location_a);
|
||||||
let n_b = numberOfInboundLegs(location_b);
|
let n_b = numberOfInboundLegs(location_b);
|
||||||
|
|
||||||
|
// 1: b vor a
|
||||||
|
// -1: a vor b
|
||||||
|
|
||||||
if (n_a == n_b) {
|
if (n_a == n_b) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (n_a > n_b) {
|
} else if (n_a > n_b) {
|
||||||
|
Reference in New Issue
Block a user