using System;
using System.Collections.Generic;
namespace MediaBrowser.Common.Extensions
{
///
/// Provides Shuffle extensions methods for .
///
public static class ShuffleExtensions
{
private static readonly Random _rng = new Random();
///
/// Shuffles the items in a list.
///
/// The list that should get shuffled.
/// The type.
public static void Shuffle(this IList list)
{
int n = list.Count;
while (n > 1)
{
n--;
int k = _rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
}