Skip to content

Commit

Permalink
Fix: Sort in browse & remote views
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MikeRatcliffe committed Sep 30, 2024
1 parent d7c7c66 commit aa85722
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions views/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down

0 comments on commit aa85722

Please sign in to comment.