diff options
| author | Vasily <JustAMan@users.noreply.github.com> | 2020-03-05 15:01:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-05 15:01:05 +0300 |
| commit | e80c9bb8c6e8fca4b1150e39518b24ef359c2998 (patch) | |
| tree | 24c3e71dde40c550a3fc01848faec5f948e18c3d /MediaBrowser.Common/Extensions | |
| parent | 434f665e81fc9899594592c1d9c4b797b651ef16 (diff) | |
| parent | 375cf212dd7ac84f073dc5b0c1df7944c1a99422 (diff) | |
Merge pull request #2513 from Bond-009/alpha
Improve 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; |
