# minPriorityQueue

> **minPriorityQueue**<`K`, `V`>(`keyOrder`, `entries?`): [`BinaryPriorityQueue`](/reference/knotkit/heap/interfaces/binarypriorityqueue/)<`K`, `V`>

Defined in: [packages/heap/src/priority-queue.ts:646](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/heap/src/priority-queue.ts#L646)

Create a min priority queue over a binary heap: the entry with the smallest key per `keyOrder` is at the root, and `pop` extracts in ascending key order.

## Type Parameters

### K

`K`

### V

`V`

## Parameters

### keyOrder

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

Total ordering over the keys.

### entries?

`Iterable`\<readonly \[`K`, `V`], `any`, `any`>

Optional initial `[key, value]` pairs, in iteration order.

## Returns

[`BinaryPriorityQueue`](/reference/knotkit/heap/interfaces/binarypriorityqueue/)<`K`, `V`>

## Example

```ts
const pq = minPriorityQueue(numberOrder, [[5, 'a'], [1, 'b'], [3, 'c']])
pq.peek() // 'b'
pq.peekEntry() // [1, 'b']
```

## Throws

With code `DUPLICATE_VALUE` when `entries` carries one value twice.
