static void Main() { int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[] { 10, 5, 7, 3, 87 }; jaggedArray[1] = new int[] { 5, 1, 12, 12, 0, 9, 8 }; jaggedArray[2] = new int[] { 1, 3, 2, 85 }; jaggedArray = JaggedSort.SortArrayMax(jaggedArray); jaggedArray = JaggedSort.SortArrayMin(jaggedArray); jaggedArray = JaggedSort.SortSumElem(jaggedArray); }
public void MinElementSort_test() { int[][] expected = { array1, array2, array3, array4 }; JaggedSort.MinElementSort(jaggedArray); Assert.AreEqual(expected, jaggedArray); }
public void SumSort_test() { int[][] expected = { array1, array4, array2, array3 }; JaggedSort.SumSort(jaggedArray); Assert.AreEqual(expected, jaggedArray); }
public void ExecuteMethod_ArraySortByMaxValueAndAscending_ReturnSortedArray() { int[][] array = new int[][] { new int[] { 1, 2, 10 }, new int[] { 5, 6, 7 }, new int[] { 0, 1, 2 } }; int[][] expected = new int[][] { new int[] { 0, 1, 2 }, new int[] { 5, 6, 7 }, new int[] { 1, 2, 10 } }; JaggedSort.Execute(array, new ComparatorMaxValueAscend()); Assert.IsTrue(CheckJaggedArrays(expected, array)); }
public void ExecuteMethod_ArrayWithEmptyElements_ReturnSortedArray() { int[][] array = new int[][] { new int[] { 1, 2, 3 }, new int[] { }, new int[] { 5, 6, 7 } }; int[][] expected = new int[][] { new int[] { 5, 6, 7 }, new int[] { 1, 2, 3 }, new int[] { } }; JaggedSort.Execute(array, new ComparatorSumDescend()); Assert.IsTrue(CheckJaggedArrays(expected, array)); }
public void ExecuteMethodWithDelegate_ArrayWithNullElements_ReturnSortedArray() { int[][] array = new int[][] { new int[] { 1, 2, 3 }, null, new int[] { 5, 6, 7 } }; int[][] expected = new int[][] { null, new int[] { 1, 2, 3 }, new int[] { 5, 6, 7 } }; ComparatorSumAscend comparator = new ComparatorSumAscend(); JaggedSort.Execute(array, comparator.Compare); Assert.IsTrue(CheckJaggedArrays(expected, array)); }
public void ExecuteMethodWithDelegate_ArraySortByMinValueAndDescending_ReturnSortedArray() { int[][] array = new int[][] { new int[] { 11, -2, 3 }, new int[] { 5, 6, 7 }, new int[] { 0, -1, 2 } }; int[][] expected = new int[][] { new int[] { 5, 6, 7 }, new int[] { 0, -1, 2 }, new int[] { 11, -2, 3 } }; ComparatorMinValueDescend comparator = new ComparatorMinValueDescend(); JaggedSort.Execute(array, comparator.Compare); Assert.IsTrue(CheckJaggedArrays(expected, array)); }