From f661268c0e8ba361b2d7cc7714d95b1e61780ea2 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Fri, 14 Mar 2025 09:28:20 +0000 Subject: [PATCH] Fix type column sorting to properly alternate between CT and VM --- frontend/src/utils/networkUtils.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/src/utils/networkUtils.js b/frontend/src/utils/networkUtils.js index 05e284250..fdbd53ada 100644 --- a/frontend/src/utils/networkUtils.js +++ b/frontend/src/utils/networkUtils.js @@ -390,20 +390,19 @@ export const getSortedAndFilteredData = ( // Special case for type column (normalize qemu/lxc to vm/ct) if (sortConfig.key === 'type') { - // Normalize type values + // Normalize type values to boolean (true for VM, false for CT) const getTypeValue = (type) => { const typeStr = (type || '').toLowerCase(); - if (typeStr === 'qemu') return 'vm'; - if (typeStr === 'lxc') return 'ct'; - return typeStr; + return typeStr === 'qemu'; }; - const aType = getTypeValue(a.type); - const bType = getTypeValue(b.type); + const aIsVM = getTypeValue(a.type); + const bIsVM = getTypeValue(b.type); + // Simple boolean comparison return sortConfig.direction === 'asc' - ? aType.localeCompare(bType) - : bType.localeCompare(aType); + ? (aIsVM === bIsVM ? 0 : aIsVM ? 1 : -1) + : (aIsVM === bIsVM ? 0 : aIsVM ? -1 : 1); } // Default string comparison for other fields