Beispiel #1
0
        public void TestSumSort(double[,] arrUnSort, bool isDesc, int row, double[,] expected)
        {
            ArraySorter sorter = new ArraySorter();
            SortBySum   sum    = new SortBySum();

            sorter.SelectMethod(sum);
            Assert.AreEqual(sorter.Sort(isDesc, arrUnSort, row), expected);
        }
Beispiel #2
0
        public void TestMaxSort(double[,] arrUnSort, bool isDesc, int row, double[,] expected)
        {
            ArraySorter sorter = new ArraySorter();
            SortByMax   max    = new SortByMax();

            sorter.SelectMethod(max);
            Assert.AreEqual(sorter.Sort(isDesc, arrUnSort, row), expected);
        }
Beispiel #3
0
        private void Sort(ISortingStrategy algorithm, long[] unsortedArray, out long[] manuallySorted, out long[] dotnetSorted)
        {
            manuallySorted = (long[])unsortedArray.Clone();
            dotnetSorted   = (long[])unsortedArray.Clone();

            ArraySorter sorter = new ArraySorter(algorithm);

            sorter.Sort(manuallySorted);

            Array.Sort(dotnetSorted);
        }
Beispiel #4
0
        public async Task <SavedData> Create(SortingInput input)
        {
            long[] array = input.GetNumbers();

            ArraySorter sorter = new ArraySorter(new MergeSort());

            sorter.Sort(array);

            string orderedNumbers = StringHelper.Concat(array);

            string fileName = await _fileService.SaveToFile(orderedNumbers);

            return(new SavedData {
                OrderedNumbers = orderedNumbers, FileName = fileName
            });
        }