Skip to content

Typed API (TypeDoc)


Typed API (TypeDoc) / heapSort

Function: heapSort()

heapSort<V>(values, comparator): FibonacciHeap<V>

Defined in: sort/index.ts:80

Type Parameters

V

V

Value type.

Parameters

values

Iterable<V>

Iterable of values to heapify.

comparator

Comparator<V>

Comparator controlling heap ordering.

Returns

FibonacciHeap<V>

Heap representation (call extractMin until empty to retrieve sorted order).

Description

Build a Fibonacci heap from values which can then be drained in order.

Example

ts
const heap = heapSort(items, numberComparatorASC)
heap.extractMin()

Remarks

Complexity: O(n) to build, O(log n) per extraction.

Built with VitePress – Released under the MIT License.