From d1d89de250d130e320c10426a600f7e8e4fe2cf7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 16 Nov 2019 11:11:03 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20IList=20overloads=20for=20?= =?UTF-8?q?Shuffle()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- X10D/ListExtensions.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/X10D/ListExtensions.cs b/X10D/ListExtensions.cs index 3c654c5..bcc7886 100644 --- a/X10D/ListExtensions.cs +++ b/X10D/ListExtensions.cs @@ -69,5 +69,24 @@ /// Returns shuffled. public static IEnumerable Shuffle(this IEnumerable source, Random random) => source.OrderBy(_ => random.Next()); + + /// + /// Shuffles a list. + /// + /// The collection type. + /// The collection to shuffle. + /// Returns shuffled. + public static IEnumerable Shuffle(this IList source) => + source.Shuffle(new Random()); + + /// + /// Shuffles a list. + /// + /// The collection type. + /// The collection to shuffle. + /// The instance. + /// Returns shuffled. + public static IEnumerable Shuffle(this IList source, Random random) => + source.OrderBy(_ => random.Next()); } }