Created
September 14, 2013 20:28
-
-
Save plioi/6565381 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Matt Howells's Shuffler from http://stackoverflow.com/a/110570 | |
public static void Shuffle<T>(this T[] array, Random random) | |
{ | |
int n = array.Length; | |
while (n > 1) | |
{ | |
int k = random.Next(n--); | |
T temp = array[n]; | |
array[n] = array[k]; | |
array[k] = temp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment