@@ -398,15 +398,20 @@ private IEnumerable<GroupDefinition> defineGroupBySource(string source)
398398 return new GroupDefinition ( 0 , source ) . Yield ( ) ;
399399 }
400400
401- private IEnumerable < GroupDefinition > defineGroupByCollection ( BeatmapInfo beatmap , IEnumerable < BeatmapCollection > collections )
401+ private IEnumerable < GroupDefinition > defineGroupByCollection ( BeatmapInfo beatmap , List < BeatmapCollection > collections )
402402 {
403403 bool anyCollections = false ;
404404
405- foreach ( var collection in collections )
405+ for ( int i = 0 ; i < collections . Count ; i ++ )
406406 {
407+ var collection = collections [ i ] ;
408+
407409 if ( collection . BeatmapMD5Hashes . Contains ( beatmap . MD5Hash ) )
408410 {
409- yield return new GroupDefinition ( 0 , collection . Name ) ;
411+ // NOTE: the ordering of the incoming collection list is significant and needs to be preserved.
412+ // the fallback to ordering by name cannot be relied on.
413+ // see xmldoc of `BeatmapCarousel.GetAllCollections()`.
414+ yield return new GroupDefinition ( i , collection . Name ) ;
410415
411416 anyCollections = true ;
412417 }
@@ -415,7 +420,7 @@ private IEnumerable<GroupDefinition> defineGroupByCollection(BeatmapInfo beatmap
415420 if ( anyCollections )
416421 yield break ;
417422
418- yield return new GroupDefinition ( 1 , "Not in collection" ) ;
423+ yield return new GroupDefinition ( int . MaxValue , "Not in collection" ) ;
419424 }
420425
421426 private IEnumerable < GroupDefinition > defineGroupByOwnMaps ( BeatmapInfo beatmap , int ? localUserId , string ? localUserUsername )
0 commit comments