Example #1
0
        public static void Shuffle()
        {
            ShuffledWordList.Clear();
            // Fisher-Yates shuffle.
            Random rnd = new Random();
            int    n   = SortedWordList.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                int    randomIndex = rnd.Next(0, i + 1); // Get random index between 0 and remaining unshuffled list item count.
                string tempString  = SortedWordList[i];
                ShuffledWordList.Add(SortedWordList[randomIndex]);
                SortedWordList[randomIndex] = tempString;
            }
            ShuffledListIsCreated = true;
        }