From c4d6fb7cd3772e94137b9e88e94c5caecfa797ad Mon Sep 17 00:00:00 2001 From: you Date: Sat, 21 Mar 2026 22:22:44 +0000 Subject: [PATCH] Fix expanded packet group observation sorting: group by observer, earliest first --- public/index.html | 2 +- public/packets.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 4a2196fe..86e8fa16 100644 --- a/public/index.html +++ b/public/index.html @@ -84,7 +84,7 @@ - + diff --git a/public/packets.js b/public/packets.js index c6027cac..9d90c14f 100644 --- a/public/packets.js +++ b/public/packets.js @@ -1216,6 +1216,21 @@ const group = packets.find(p => p.hash === hash); if (group && data.observations) { group._children = data.observations.map(o => ({...pkt, ...o, _isObservation: true})); + // Sort: group by observer, earliest-observer first, then by time within each observer + const earliest = {}; + for (const c of group._children) { + const obs = c.observer || ''; + const t = c.rx_at || c.created_at || ''; + if (!earliest[obs] || t < earliest[obs]) earliest[obs] = t; + } + group._children.sort((a, b) => { + const oA = a.observer || '', oB = b.observer || ''; + const eA = earliest[oA] || '', eB = earliest[oB] || ''; + if (eA !== eB) return eA < eB ? -1 : 1; + if (oA !== oB) return oA < oB ? -1 : 1; + const tA = a.rx_at || a.created_at || '', tB = b.rx_at || b.created_at || ''; + return tA < tB ? -1 : tA > tB ? 1 : 0; + }); } // Resolve any new hops from children const childHops = new Set();