/// <summary> /// Sort Ascending then find media. Haha!!! /// </summary> /// <returns></returns> //public static T FindMedian(T[] inputArray) //{ //} private static T[] SortFromMaxHeapDescending(MaxHeap <T> maxHeap) { T[] elementsToSort = new T[maxHeap.GetHeapCount()]; int startIndex = 0; while (!maxHeap.IsEmpty()) { elementsToSort[startIndex] = maxHeap.DeleteItem(0); startIndex++; } return(elementsToSort); }
public static T[] SortDescending(ReadOnlySpan <T> unsortedArray) { var heap = new MaxHeap <T>(unsortedArray); return(SortFromMaxHeapDescending(heap)); }