diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index 3e05451bed..12247c3997 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; @@ -23,6 +24,8 @@ namespace osu.Game.Database [OneToMany(CascadeOperations = CascadeOperation.All)] public List Beatmaps { get; set; } + public float MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty); + public bool DeletePending { get; set; } public string Hash { get; set; } diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 7de7779bd0..092e4461e0 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -173,28 +173,7 @@ namespace osu.Game.Screens.Select sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase)); break; case SortMode.Difficulty: - sortedGroups.Sort((x, y) => - { - float xAverage = 0, yAverage = 0; - int counter = 0; - foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) - { - xAverage += set.StarDifficulty; - counter++; - } - xAverage /= counter; - counter = 0; - foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) - { - yAverage += set.StarDifficulty; - counter++; - } - yAverage /= counter; - if (xAverage > yAverage) - return 1; - else - return -1; - }); + sortedGroups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty)); break; default: Sort(SortMode.Artist); // Temporary