# maxPriorityQueue

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

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

Create a max priority queue over a binary heap: the entry with the largest key per `keyOrder` is at the root, and `pop` extracts in descending 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 = maxPriorityQueue(numberOrder, [[5, 'a'], [1, 'b'], [3, 'c']])
pq.peek() // 'a'
```

## Throws

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