using System; using System.Collections.Generic; namespace Jellyfin.Extensions { /// /// Provides Shuffle extensions methods for . /// public static class ShuffleExtensions { /// /// Shuffles the items in a list. /// /// The list that should get shuffled. /// The type. public static void Shuffle(this IList list) { list.Shuffle(Random.Shared); } /// /// Shuffles the items in a list. /// /// The list that should get shuffled. /// The random number generator to use. /// The type. public static void Shuffle(this IList list, Random rng) { int n = list.Count; while (n > 1) { int k = rng.Next(n--); T value = list[k]; list[k] = list[n]; list[n] = value; } } } }