Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

fix: apply natural sorting for item names (#607)

mygrexitca612a138f0d
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;