---
lang: en
title: 'API docs: context.sortbindingsbyphase'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context
permalink: /doc/en/lb4/apidocs.context.sortbindingsbyphase.html
---

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

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [sortBindingsByPhase](./context.sortbindingsbyphase.md)

## sortBindingsByPhase() function

Sort bindings by phase names denoted by a tag and the predefined order

**Signature:**

```typescript
export declare function sortBindingsByPhase<T = unknown>(bindings: Readonly<Binding<T>>[], phaseTagName?: string, orderOfPhases?: (string | symbol)[]): Readonly<Binding<T>>[];
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

bindings


</td><td>

Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;T&gt;&gt;\[\]


</td><td>

An array of bindings


</td></tr>
<tr><td>

phaseTagName


</td><td>

string


</td><td>

_(Optional)_ Tag name for phase, for example, we can use the value `'a'` of tag `order` as the phase name for `binding.tag({order: 'a'})`<!-- -->.


</td></tr>
<tr><td>

orderOfPhases


</td><td>

(string \| symbol)\[\]


</td><td>

_(Optional)_ An array of phase names as the predefined order


</td></tr>
</tbody></table>

**Returns:**

Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;T&gt;&gt;\[\]


