From ca612a138f0df11f92c5a1de7a2aece46648a69a Mon Sep 17 00:00:00 2001 From: mygrexit <33792951+mygrexit@users.noreply.github.com> Date: Thu, 27 Mar 2025 01:31:49 +0100 Subject: [PATCH] fix: apply natural sorting for item names (#607) --- frontend/components/Item/View/Table.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/components/Item/View/Table.vue b/frontend/components/Item/View/Table.vue index 53d2f173..8fadf7a4 100644 --- a/frontend/components/Item/View/Table.vue +++ b/frontend/components/Item/View/Table.vue @@ -249,13 +249,17 @@ return 0; } - const aLower = extractSortable(a, sortByProperty.value); - const bLower = extractSortable(b, sortByProperty.value); + const aVal = extractSortable(a, sortByProperty.value); + const bVal = extractSortable(b, sortByProperty.value); - if (aLower < bLower) { + if (typeof aVal === "string" && typeof bVal === "string") { + return aVal.localeCompare(bVal, undefined, { numeric: true, sensitivity: "base" }); + } + + if (aVal < bVal) { return -1; } - if (aLower > bLower) { + if (aVal > bVal) { return 1; } return 0;