<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/database](./database.md) &gt; [orderByKey](./database.orderbykey.md)

## orderByKey() function

Creates a new `QueryConstraint` that orders by the key.

Sorts the results of a query by their (ascending) key values.

You can read more about `orderByKey()` in [Sort data](https://firebase.google.com/docs/database/web/lists-of-data#sort_data)<!-- -->.

<b>Signature:</b>

```typescript
export declare function orderByKey(): QueryConstraint;
```
<b>Returns:</b>

[QueryConstraint](./database.queryconstraint.md)

