Skip to content

Commit

Permalink
improvement: ignore "the" in artist names for sorting purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshankman committed Nov 14, 2023
1 parent f5362b1 commit 62d29c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ ipcMain.on('select-library', async (event): Promise<any> => {
const orderedFilesToTags: { [key: string]: SongSkeletonStructure } = {};
Object.keys(filesToTags)
.sort((a, b) => {
const artistA = filesToTags[a].common?.artist?.toLowerCase();
const artistB = filesToTags[b].common?.artist?.toLowerCase();
const artistA = filesToTags[a].common?.artist
?.toLowerCase()
.replace(/^the /, '');
const artistB = filesToTags[b].common?.artist
?.toLowerCase()
.replace(/^the /, '');
const albumA = filesToTags[a].common?.album?.toLowerCase();
const albumB = filesToTags[b].common?.album?.toLowerCase();
const trackA = filesToTags[a].common?.track?.no;
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,12 @@ function MainDash() {
setFilterDirection(filterDirection === 'asc' ? 'desc' : 'asc');

const filtered = Object.keys(filteredLibrary).sort((a, b) => {
const artistA = filteredLibrary[a].common?.artist?.toLowerCase();
const artistB = filteredLibrary[b].common?.artist?.toLowerCase();
const artistA = filteredLibrary[a].common?.artist
?.toLowerCase()
.replace(/^the /, '');
const artistB = filteredLibrary[b].common?.artist
?.toLowerCase()
.replace(/^the /, '');
const albumA = filteredLibrary[a].common?.album?.toLowerCase();
const albumB = filteredLibrary[b].common?.album?.toLowerCase();
const trackA = filteredLibrary[a].common?.track?.no;
Expand Down

0 comments on commit 62d29c0

Please sign in to comment.