1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

Maintain sort stability by using carousel item ID as fallback

This commit is contained in:
Salman Ahmed 2022-07-26 09:36:25 +03:00
parent 4efe09e7c2
commit d7ef4170be

View File

@ -24,6 +24,7 @@ namespace osu.Game.Screens.Select.Carousel
private ulong currentChildID;
private Comparer<CarouselItem>? criteriaComparer;
private Comparer<CarouselItem>? itemIDComparer;
private FilterCriteria? lastCriteria;
@ -90,7 +91,8 @@ namespace osu.Game.Screens.Select.Carousel
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
items = items.OrderBy(c => c, criteriaComparer).ToList();
itemIDComparer = Comparer<CarouselItem>.Create((x, y) => x.ChildID.CompareTo(y.ChildID));
items = items.OrderBy(c => c, criteriaComparer).ThenBy(c => c, itemIDComparer).ToList();
lastCriteria = criteria;
}