mixedcards/Assets/ListShuffle.cs
2020-09-19 13:52:16 -04:00

18 lines
397 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class ListShuffle
{
public static void Shuffle<T>(this IList<T> list)
{
int n = list.Count;
while (n > 1) {
int k = Random.Range(0, n);
n--;
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}