1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Merge pull request #27692 from bdach/artist-sort-uses-title-as-tiebreaker

Use title as tiebreaker when sorting beatmap carousel by artist
This commit is contained in:
Dan Balasescu 2024-03-22 17:15:40 +09:00 committed by GitHub
commit 77660e57ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 0 deletions

View File

@ -666,6 +666,56 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert($"Check {zzz_lowercase} is second last", () => carousel.BeatmapSets.SkipLast(1).Last().Metadata.Artist == zzz_lowercase);
}
[Test]
public void TestSortByArtistUsesTitleAsTiebreaker()
{
var sets = new List<BeatmapSetInfo>();
AddStep("Populuate beatmap sets", () =>
{
sets.Clear();
for (int i = 0; i < 20; i++)
{
var set = TestResources.CreateTestBeatmapSetInfo();
if (i == 4)
{
set.Beatmaps.ForEach(b =>
{
b.Metadata.Artist = "ZZZ";
b.Metadata.Title = "AAA";
});
}
if (i == 8)
{
set.Beatmaps.ForEach(b =>
{
b.Metadata.Artist = "ZZZ";
b.Metadata.Title = "ZZZ";
});
}
sets.Add(set);
}
});
loadBeatmaps(sets);
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
AddAssert("Check last item", () =>
{
var lastItem = carousel.BeatmapSets.Last();
return lastItem.Metadata.Artist == "ZZZ" && lastItem.Metadata.Title == "ZZZ";
});
AddAssert("Check second last item", () =>
{
var secondLastItem = carousel.BeatmapSets.SkipLast(1).Last();
return secondLastItem.Metadata.Artist == "ZZZ" && secondLastItem.Metadata.Title == "AAA";
});
}
/// <summary>
/// Ensures stability is maintained on different sort modes for items with equal properties.
/// </summary>

View File

@ -69,6 +69,8 @@ namespace osu.Game.Screens.Select.Carousel
default:
case SortMode.Artist:
comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist);
if (comparison == 0)
goto case SortMode.Title;
break;
case SortMode.Title: