# compareBytes

> **compareBytes**(`left`, `right`): `-1` | `0` | `1`

Defined in: [packages/key-encoding/src/bytes.ts:12](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/key-encoding/src/bytes.ts#L12)

Compare two byte strings in unsigned lexicographic order, the order an encoded key sorts in.

A proper prefix sorts before every longer string that extends it. The result is `-1`, `0`, or `1`, so the function is an `Order<Uint8Array>` for `knotkit/heap`, `knotkit/ordered-map`, `knotkit/sorted-merge`, or `Array.prototype.sort`.

Runs in O(min(left.byteLength, right.byteLength)) and does not validate its arguments, because it sits on the hot path of every comparison-based structure; pass `Uint8Array` values.

## Parameters

### left

`Uint8Array`

### right

`Uint8Array`

## Returns

`-1` | `0` | `1`
