Exemple #1
0
        public static void HeapSort <T>(this T[] array, IComparer <T> comparer)
        {
            var sortingHeap = new Heap <T>(array.Length, comparer);

            foreach (T arrayElement in array)
            {
                sortingHeap.Add(arrayElement);
            }

            while (sortingHeap.Count > 0)
            {
                array[array.Length - sortingHeap.Count] = sortingHeap.DeleteTop();
            }
        }