Esempio n. 1
0
        public static void ShuffleNumbers(IList <int> numberArray)
        {
            Random random = new Random();

            for (int i = 0; i < numberArray.Count - 1; i++)
            {
                int randomIndex = random.Next(i, numberArray.Count);

                ArrayInteraction <int> .SwapValues(numberArray, i, randomIndex);
            }
        }
Esempio n. 2
0
        public static void Sort(IList <int> items)
        {
            for (int i = 1; i < items.Count; i++)
            {
                int j = i;

                while (j > 0 && items[j - 1] > items[j])
                {
                    ArrayInteraction <int> .SwapValues(items, j - 1, j);

                    j--;
                }
            }
        }
Esempio n. 3
0
        public static void Sort(IList <int> items)
        {
            int currentIndex  = int.MinValue;
            int smallestindex = 0;

            for (int i = 0; i < items.Count; i++)
            {
                smallestindex = i;

                for (int j = i; j < items.Count; j++)
                {
                    currentIndex = j;

                    if (items[currentIndex] < items[smallestindex])
                    {
                        smallestindex = currentIndex;
                    }
                }

                ArrayInteraction <int> .SwapValues(items, i, smallestindex);
            }
        }