Add tests for alpha numeric sorting

This commit is contained in:
Bond_009
2020-03-05 00:54:46 +01:00
parent a987b68f7c
commit ada3f96668
4 changed files with 83 additions and 1 deletions

View File

@@ -16,12 +16,23 @@ namespace MediaBrowser.Common.Extensions
/// <param name="list">The list that should get shuffled.</param>
/// <typeparam name="T">The type.</typeparam>
public static void Shuffle<T>(this IList<T> list)
{
list.Shuffle(_rng);
}
/// <summary>
/// Shuffles the items in a list.
/// </summary>
/// <param name="list">The list that should get shuffled.</param>
/// <param name="rng">The random number generator to use.</param>
/// <typeparam name="T">The type.</typeparam>
public static void Shuffle<T>(this IList<T> list, Random rng)
{
int n = list.Count;
while (n > 1)
{
n--;
int k = _rng.Next(n + 1);
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;