# minBinaryHeap

> **minBinaryHeap**<`A`>(`order`, `items?`): [`BinaryHeap`](/reference/knotkit/heap/interfaces/binaryheap/)<`A`>

Defined in: [packages/heap/src/binary-heap.ts:341](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/heap/src/binary-heap.ts#L341)

Create a min binary heap: the smallest element per `order` is at the root, and `pop` extracts in ascending order.

## Type Parameters

### A

`A`

## Parameters

### order

[`Order`](/reference/knotkit/heap/type-aliases/order/)<`A`>

Total ordering over the elements.

### items?

`Iterable`<`A`, `any`, `any`>

Optional initial elements, in iteration order.

## Returns

[`BinaryHeap`](/reference/knotkit/heap/interfaces/binaryheap/)<`A`>

## Example

```ts
const heap = minBinaryHeap(numberOrder, [30, 1, 50, 20])
heap.peek() // 1
```
