Пример #1
0
        public void MergeSort_Sort_IsSorted()
        {
            // Arrange
            var shuffledList = new SortableList(isRandom: true, content: sequence.ToArray());

            // Act
            shuffledList.MergeSort();

            // Assert
            // Because the SortedList class does not implement ICollection or IEnumerable, comparison must be done by hand.
            for (var i = 0; i < sequence.Count; i++)
            {
                shuffledList[i].Should().Be(sequence[i], because: "the list should be sorted and the original list was sorted");
            }
        }
Пример #2
0
        internal static void Main(string[] args)
        {
            var numbers = NumberStream.GetIncrementingIntegerStream().Take(10).ToArray();

            var list = new SortableList(true, numbers);

            Console.WriteLine("Before sorting:");
            PrintList(list);
            Console.WriteLine();

            list.MergeSort();

            Console.WriteLine("After sorting:");
            PrintList(list);
        }