diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-03-05 00:54:46 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-03-05 00:54:46 +0100 |
| commit | ada3f966681070823be3eefae9a0f77a31b1994f (patch) | |
| tree | a9e42379c6eb2828b4ab3b3c38640e1e6ed5331a /MediaBrowser.Common/Extensions | |
| parent | a987b68f7c80145ed1fd211ba07b2ad3cc186c6f (diff) | |
Add tests for alpha numeric sorting
Diffstat (limited to 'MediaBrowser.Common/Extensions')
| -rw-r--r-- | MediaBrowser.Common/Extensions/ShuffleExtensions.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs index 5889d09c4..0432f36b5 100644 --- a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs +++ b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs @@ -17,11 +17,22 @@ namespace MediaBrowser.Common.Extensions /// <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; |
