From 763be8532d2b61d0b4d45e72343f6a2e5fee1db9 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 5 Mar 2022 21:58:56 +0100 Subject: [PATCH] fix: wrong soft sort algorithm for numeric fields, closes #199 --- src/renderer/components/WorkspaceTabQueryTable.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/WorkspaceTabQueryTable.vue b/src/renderer/components/WorkspaceTabQueryTable.vue index fbd33279..08283527 100644 --- a/src/renderer/components/WorkspaceTabQueryTable.vue +++ b/src/renderer/components/WorkspaceTabQueryTable.vue @@ -175,8 +175,10 @@ export default { if (this.currentSort && !this.isHardSort) { return [...this.localResults].sort((a, b) => { let modifier = 1; - const valA = typeof a[this.currentSort] === 'string' ? a[this.currentSort].toLowerCase() : a[this.currentSort]; - const valB = typeof b[this.currentSort] === 'string' ? b[this.currentSort].toLowerCase() : b[this.currentSort]; + let valA = typeof a[this.currentSort] === 'string' ? a[this.currentSort].toLowerCase() : a[this.currentSort]; + if (!isNaN(valA)) valA = Number(valA); + let valB = typeof b[this.currentSort] === 'string' ? b[this.currentSort].toLowerCase() : b[this.currentSort]; + if (!isNaN(valB)) valB = Number(valB); if (this.currentSortDir === 'desc') modifier = -1; if (valA < valB) return -1 * modifier; if (valA > valB) return 1 * modifier;