diff --git a/public/hop-resolver.js b/public/hop-resolver.js index 8cad87f0..8497a047 100644 --- a/public/hop-resolver.js +++ b/public/hop-resolver.js @@ -106,6 +106,7 @@ window.HopResolver = (function() { return { ...c, regional: r ? r.near : false, filterMethod: r ? r.method : 'none', distKm: r ? r.distKm : undefined }; }); const regional = checked.filter(c => c.regional); + regional.sort((a, b) => (a.distKm || 9999) - (b.distKm || 9999)); const candidates = regional.length > 0 ? regional : checked; const globalFallback = regional.length === 0 && checked.length > 0 && packetIata != null; diff --git a/public/index.html b/public/index.html index 1e1892b0..2e590ba4 100644 --- a/public/index.html +++ b/public/index.html @@ -82,7 +82,7 @@ - + diff --git a/server.js b/server.js index e5773075..d331b100 100644 --- a/server.js +++ b/server.js @@ -2097,6 +2097,8 @@ app.get('/api/resolve-hops', (req, res) => { return { ...c, regional: r.near, filterMethod: r.method, distKm: r.distKm }; }); const regional = checked.filter(c => c.regional); + // Sort by distance to region center — closest first + regional.sort((a, b) => (a.distKm || 9999) - (b.distKm || 9999)); const candidates = regional.length > 0 ? regional : checked; const globalFallback = regional.length === 0 && checked.length > 0;