From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id BE8E01FF0AB for ; Wed, 23 Sep 2026 15:19:12 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8A60621244; Wed, 23 Sep 2026 15:19:03 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v4 09/10] ui: pve: node selector: sort memory columns by usage not by memory size Date: Wed, 23 Sep 2026 15:17:09 +0200 Message-ID: <20260923131857.2953139-10-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260923131857.2953139-1-d.csapak@proxmox.com> References: <20260923131857.2953139-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.439 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: KOBU75TWIPZ5BXQ7GQ46B3IHLIGSP5PZ X-Message-ID-Hash: KOBU75TWIPZ5BXQ7GQ46B3IHLIGSP5PZ 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