From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 9CAD21FF0B7 for ; Fri, 02 Oct 2026 16:14:55 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4891721446; Fri, 02 Oct 2026 16:14:54 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v5 09/10] ui: pve: node selector: sort memory columns by usage not by memory size Date: Fri, 2 Oct 2026 16:13:13 +0200 Message-ID: <20261002141448.3336388-10-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261002141448.3336388-1-d.csapak@proxmox.com> References: <20261002141448.3336388-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.415 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: DA7F2XAMVWEFE4SKTNMIOSKXWTWIH7UE X-Message-ID-Hash: DA7F2XAMVWEFE4SKTNMIOSKXWTWIH7UE X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We only show the usage, so it makes sense to sort by that instead of the raw memory size value. Use total_cmp for floats, which sorts (+/-)NaN/Infinity separate from finite values. Signed-off-by: Dominik Csapak --- ui/src/widget/pve_node_selector.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/src/widget/pve_node_selector.rs b/ui/src/widget/pve_node_selector.rs index d471780e..5882f532 100644 --- a/ui/src/widget/pve_node_selector.rs +++ b/ui/src/widget/pve_node_selector.rs @@ -261,7 +261,11 @@ fn columns(show_memory: bool) -> Rc>> { } html! {format!("{:.2}%", 100.0 * entry.mem as f64 / entry.maxmem as f64)} }) - .sorter(|a: &PveNodeResource, b: &PveNodeResource| a.mem.cmp(&b.mem)) + .sorter(|a: &PveNodeResource, b: &PveNodeResource| { + let a = (a.mem as f64) / (a.maxmem as f64); + let b = (b.mem as f64) / (b.maxmem as f64); + a.total_cmp(&b) + }) .into(), ); } -- 2.47.3