Skip to content

Instantly share code, notes, and snippets.

@guanqun
Created October 21, 2013 04:15
Show Gist options
  • Save guanqun/7078593 to your computer and use it in GitHub Desktop.
Save guanqun/7078593 to your computer and use it in GitHub Desktop.
[Extension]
public static class ListUtils
{
[Extension]
public static void Shuffle<T>(IList<T> list)
{
int count = list.Count;
while (count > 1)
{
count--;
int num2 = Random.Range(0, count + 1);
T local = list[num2];
list[num2] = list[count];
list[count] = local;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment