From 7d2369252e35796001a3a0c4f52877827c21493f Mon Sep 17 00:00:00 2001 From: mbrucedogs Date: Mon, 21 Jul 2025 12:23:51 -0500 Subject: [PATCH] fixed search/songs Signed-off-by: mbrucedogs --- src/utils/dataProcessing.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/utils/dataProcessing.ts b/src/utils/dataProcessing.ts index fca48b2..6584102 100644 --- a/src/utils/dataProcessing.ts +++ b/src/utils/dataProcessing.ts @@ -70,17 +70,16 @@ export const sortTopPlayedByCount = (songs: TopPlayed[]): TopPlayed[] => { // Sort songs by artist then title (case insensitive) export const sortSongsByArtistAndTitle = (songs: Song[]): Song[] => { const sortedSongs = [...songs].sort((a, b) => { - // First sort by artist (case insensitive) - const artistA = a.artist.toLowerCase(); - const artistB = b.artist.toLowerCase(); + // Defensive: treat missing artist/title as empty string + const artistA = (a.artist || '').toLowerCase(); + const artistB = (b.artist || '').toLowerCase(); if (artistA !== artistB) { return artistA.localeCompare(artistB); } - // If artists are the same, sort by title (case insensitive) - const titleA = a.title.toLowerCase(); - const titleB = b.title.toLowerCase(); + const titleA = (a.title || '').toLowerCase(); + const titleB = (b.title || '').toLowerCase(); return titleA.localeCompare(titleB); });