From aa85722b412972b2c6a5164c6139d8accbeb3782 Mon Sep 17 00:00:00 2001 From: Mike Ratcliffe <michael@ratcliffefamily.org> Date: Wed, 18 Sep 2024 16:03:42 +0100 Subject: [PATCH] Fix: Sort in browse & remote views This commit addresses an issue with sorting functionality in the "browse" and "remote" views within the application. The previous implementation of the `sortBy` function contained a nested function, which completely broke the sort functionality. This change also simplifies the `sortBy` function by making the sorting logic more straightforward and easier to understand. This improved clarity and maintainability will benefit developers working on the codebase. --- views/js/search.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/views/js/search.js b/views/js/search.js index 953854a..b117db1 100644 --- a/views/js/search.js +++ b/views/js/search.js @@ -320,19 +320,17 @@ function openSearch() { */ function sortBy(key, asc) { return (a, b) => { - return (a, b) => { - var valA = $(a).data(key); - var valB = $(b).data(key); - if (valA < valB) { - return asc ? -1 : 1; - } - - if (valA > valB) { - return asc ? 1 : -1; - } - - return 0; - }; + var valA = $(a).data(key); + var valB = $(b).data(key); + if (valA < valB) { + return asc ? -1 : 1; + } + + if (valA > valB) { + return asc ? 1 : -1; + } + + return 0; }; }