Ejemplo n.º 1
0
        public int[] Sort(int[] items)
        {
            Heap heap = new Heap(items);
            buildMaxHeap(heap);

            for (int i = heap.Length - 1; i > 0; i--)
            {
                heap.Swap(0, i);
                heap.HeapSize--;
                maxHeapify(heap, 0);
            }

            return heap.AsArray();
        }