MergeSort - a stable sort for .Net Mostly a translation of the C++ mergesort from Robert Sedgewick's Algorithms in C++, 1st edition This implementations supports Arrays and ArrayLists. Because of .Net limitations primitive arrays (example: int [] array = new int[10000];) cannot be sorted by this code.
Inheritance: IFWDisposable
示例#1
0
		/// <summary>
		/// Sort an ArrayList using the specified comparer
		/// </summary>
		/// <param name="array">ArrayList to sort</param>
		/// <param name="compare">Comparer to used for sorting</param>
		public static void Sort(ref System.Collections.ArrayList array, System.Collections.IComparer compare)
		{
			using (MergeSort mergeSort = new MergeSort())
			{
				mergeSort.InternalSort(ref array, 0, array.Count - 1, compare);
			}
		}
示例#2
0
		/// <summary>
		/// Sort an array using the default comparer
		/// </summary>
		/// <param name="array">array to be sorted</param>
		public static void Sort(ref Array array)
		{
			using (MergeSort mergeSort = new MergeSort())
			{
				mergeSort.InternalSort(ref array, 0, array.Length - 1, System.Collections.Comparer.Default);
			}
		}