Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2013 14:26
Show Gist options
  • Save anonymous/7564070 to your computer and use it in GitHub Desktop.
Save anonymous/7564070 to your computer and use it in GitHub Desktop.
public T[] Shuffle<T>(T[] array)
{
Random rnd = new Random();
for (int i = 0; i < array.Length; ++i)
{
int idx = rnd.Next(array.Length);
T tmp = array[i];
array[i] = array[idx];
array[idx] = tmp;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment