---
url: >-
  https://lit-ui-router.dev/reference/ui-router-server/matcher/functions/compare.md
---
[ui-router-server](../../index.md) / [matcher](../index.md) / compare

# Function: compare()

```ts
function compare(a, b): number;
```

Defined in: [url-matcher.ts:613](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-server/src/url-matcher.ts#L613)

Sorts two compiled matchers by static specificity, as core's
UrlMatcher.compare: path tokens compared position-by-position, slash
before static text before a param. Negative means `a` is more specific
than `b`. Single-matcher only: matchers here never `append`.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `a` | [`CompiledMatcher`](../interfaces/CompiledMatcher.md)<`unknown`> |
| `b` | [`CompiledMatcher`](../interfaces/CompiledMatcher.md)<`unknown`> |

## Returns

`number`
