Skip to content

Instantly share code, notes, and snippets.

@plioi
Created September 14, 2013 20:28
Show Gist options
  • Save plioi/6565381 to your computer and use it in GitHub Desktop.
Save plioi/6565381 to your computer and use it in GitHub Desktop.
//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