---
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

<b>Signature:</b>

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

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  bindings | Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;T&gt;&gt;\[\] | An array of bindings |
|  phaseTagName | string | <i>(Optional)</i> Tag name for phase, for example, we can use the value <code>'a'</code> of tag <code>order</code> as the phase name for <code>binding.tag({order: 'a'})</code>. |
|  orderOfPhases | (string \| symbol)\[\] | <i>(Optional)</i> An array of phase names as the predefined order |

<b>Returns:</b>

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


