Skip to content

Commit

Permalink
Fix sorting of titles that start with 'the'
Browse files Browse the repository at this point in the history
Because the titles that come from the library data aren't titlecased,
a title like 'The arrest' was being normalised to 'arrest', which sorts
after titles that start with B-Z.  Lowercasing everything makes the sort
more consistent.
  • Loading branch information
alexwlchan committed Feb 25, 2024
1 parent 6d51fbc commit 519bf8a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/library_lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ function renderBooks() {
} else if (a.locallyAvailableCopies === 0 & b.locallyAvailableCopies > 0) {
return 1;
} else {
const sortTitleA = a.title.replace(/^The /, '');
const sortTitleB = b.title.replace(/^The /, '');
const sortTitleA = a.title.replace(/^The /, '').toLowerCase();
const sortTitleB = b.title.replace(/^The /, '').toLowerCase();

return sortTitleA > sortTitleB ? 1 : -1;
}
Expand Down

0 comments on commit 519bf8a

Please sign in to comment.