public void Sort(int[][] array, ISorterType sorterTypeObject) { if (array == null) throw new ArgumentNullException(); if (sorterTypeObject==null) throw new ArgumentNullException(); int[] subArray = new int[array.GetLength(0)]; for (int i = 0; i < array.GetLength(0); i++) { if (array[i] == null) subArray[i] = int.MaxValue; else { subArray[i] = sorterTypeObject.CalculateFaktor(array[i]); } } for (int i = 0; i < array.GetLength(0); i++) { for (int j = 0; j < array.GetLength(0) - 1; j++) { if (sorterTypeObject.AscendingOrder ? subArray[j] > subArray[j + 1] : subArray[j] < subArray[j + 1]) { Swap(ref subArray[j], ref subArray[j + 1]); Swap(ref array[j], ref array[j + 1]); } } } }
public void Sort(int[][] ar, bool asc, ISorterType sorterTypeObject) { if (ar == null) throw new NullReferenceException(); int[] subArray = new int[ar.GetLength(0)]; for (int i = 0; i < ar.GetLength(0); i++) { if (ar[i] == null) subArray[i] = int.MaxValue; else { subArray[i] = sorterTypeObject.CalculateFaktor(ar[i]); } } for (int i = 0; i < ar.GetLength(0); i++) { for (int j = 0; j < ar.GetLength(0) - 1; j++) { if (asc ? subArray[j] > subArray[j + 1] : subArray[j] < subArray[j + 1]) { Swap(ref subArray[j], ref subArray[j + 1]); Swap(ref ar[j], ref ar[j + 1]); } } } }
public void AddSorterObjectToCollection(ISorterType sorterTypeObject) { _sorterTypes.Add(sorterTypeObject); }