/// <summary> /// Performs a quick sort on the specified range and returns an array of new /// model row or column indexes for the range. /// </summary> /// <param name="row">The row index.</param> /// <param name="column">The column index.</param> /// <param name="rowCount">The row count.</param> /// <param name="columnCount">The column coun.t</param> /// <param name="byRows">If set to <c>true</c>, [by rows]</param> /// <param name="sortInfo">The sort information.</param> /// <param name="sortingAlgorithmType">The sorting algorithm type.</param> /// <returns>Return result</returns> public int[] QuickSort(int row, int column, int rowCount, int columnCount, bool byRows, SortInfo[] sortInfo, SortingAlgorithmType sortingAlgorithmType) { int num2; int num = byRows ? rowCount : columnCount; int[] list = new int[num]; if (byRows) { for (num2 = 0; num2 < num; num2++) { list[num2] = this.worksheet.GetModelRowFromViewRow(row + num2); } } else { for (num2 = 0; num2 < num; num2++) { list[num2] = this.worksheet.GetModelColumnFromViewColumn(column + num2); } } using (SpreadSortComparer comparer = new SpreadSortComparer(this.worksheet, byRows, sortInfo)) { switch (sortingAlgorithmType) { case SortingAlgorithmType.QuickSort: Array.Sort(list, 0, num, comparer); break; case SortingAlgorithmType.BubbleSort: this.BubbleSort(list, comparer); break; case SortingAlgorithmType.InsertionSort: this.InsertionSort(list, comparer); break; default: Array.Sort(list, 0, num, comparer); break; } this.BubbleSort(list, comparer); } return(list); }
// Output passed DataTable, Elapsed Time and SortType public static void OutputData(string[] DataTable, double SortTime, SortType SortParameters, SortingAlgorithmType SortAlgorithm) { for (int i = 0; i < DataTable.Length; i++) { Console.WriteLine(DataTable[i]); } Console.WriteLine("=========================================="); Console.WriteLine($"Data Sort Time: {SortTime} ms, Sorting by {SortParameters}, Using {SortAlgorithm}"); }