# maxBinaryHeap

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

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

Create a max binary heap: the largest element per `order` is at the root, and `pop` extracts in descending 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 = maxBinaryHeap(numberOrder, [30, 1, 50, 20])
heap.peek() // 50
```
