From 2149fed8c5b3d1c8120268a878a9fe50b33cc022 Mon Sep 17 00:00:00 2001 From: Pablo Revilla Date: Sun, 30 Nov 2025 10:38:18 -0800 Subject: [PATCH] Fixed Sort nodes by firmware in nodelist.html --- meshview/templates/nodelist.html | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/meshview/templates/nodelist.html b/meshview/templates/nodelist.html index 9522f77..ea39bd6 100644 --- a/meshview/templates/nodelist.html +++ b/meshview/templates/nodelist.html @@ -434,22 +434,25 @@ document.addEventListener("DOMContentLoaded", async function() { // ===================================================== // SORT NODES // ===================================================== - function sortNodes(nodes, key, asc) { - return [...nodes].sort((a, b) => { - let A = a[key]; - let B = b[key]; +function sortNodes(nodes, key, asc) { + return [...nodes].sort((a, b) => { + let A = a[key]; + let B = b[key]; - // special handling for timestamp - if (key === "last_seen_us") { - A = A || 0; - B = B || 0; - } + // Normalize null/undefined/empty to a sortable string + A = (A ?? "").toString().toLowerCase(); + B = (B ?? "").toString().toLowerCase(); + + // Force "n/a" to sort last + if (A === "" || A === "n/a") A = "~"; + if (B === "" || B === "n/a") B = "~"; + + if (A < B) return asc ? -1 : 1; + if (A > B) return asc ? 1 : -1; + return 0; + }); +} - if (A < B) return asc ? -1 : 1; - if (A > B) return asc ? 1 : -1; - return 0; - }); - } // ===================================================== // SORT ICONS