Skip to content

Commit 742aee3

Browse files
committed
handle extemes
1 parent 51f156d commit 742aee3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ui/SongListLayer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,12 @@ bool SongListLayer::dateAdded(MLRSongCell* a, MLRSongCell* b, const bool reverse
627627

628628
bool SongListLayer::songLength(MLRSongCell* a, MLRSongCell* b, const bool reverse = false) {
629629
if (SONG_SORTING_DISABLED) return false;
630+
const unsigned int extreme = reverse ? std::numeric_limits<unsigned int>::min() : std::numeric_limits<unsigned int>::max();
631+
if (a->m_songData.songLength == extreme || b->m_songData.songLength == extreme) {
632+
if (a->m_songData.songLength == extreme && b->m_songData.songLength == extreme) return a->m_songData.actualFilePath < b->m_songData.actualFilePath;
633+
if (a->m_songData.songLength == extreme) return reverse;
634+
if (b->m_songData.songLength == extreme) return !reverse;
635+
}
630636
if (a->m_songData.songLength < b->m_songData.songLength) return !reverse;
631637
if (a->m_songData.songLength > b->m_songData.songLength) return reverse;
632638
return a->m_songData.actualFilePath < b->m_songData.actualFilePath;

0 commit comments

Comments
 (0)