Avoid duplicate Best Value rank crashes
This commit is contained in:
@@ -499,11 +499,12 @@ enum FuelSavingsEstimator {
|
||||
pricePencePerLitre: station.prices[fuel] ?? .infinity
|
||||
)
|
||||
}
|
||||
let order = Dictionary(
|
||||
uniqueKeysWithValues: FuelSavingsCalculator.sortedForWorthTheDrive(ranked)
|
||||
.enumerated()
|
||||
.map { ($0.element.stationID, $0.offset) }
|
||||
)
|
||||
var order: [String: Int] = [:]
|
||||
for (offset, rankedStation) in FuelSavingsCalculator.sortedForWorthTheDrive(ranked).enumerated() {
|
||||
if order[rankedStation.stationID] == nil {
|
||||
order[rankedStation.stationID] = offset
|
||||
}
|
||||
}
|
||||
return stations.sorted { lhs, rhs in
|
||||
let left = order[lhs.id] ?? Int.max
|
||||
let right = order[rhs.id] ?? Int.max
|
||||
|
||||
Reference in New Issue
Block a user