UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

43 lines (27 loc) 1.49 kB
--- lang: en title: 'API docs: context.comparebyorder' 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.comparebyorder.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [compareByOrder](./context.comparebyorder.md) ## compareByOrder() function Compare two values by the predefined order <b>Signature:</b> ```typescript export declare function compareByOrder(a: string | symbol | undefined | null, b: string | symbol | undefined | null, order?: (string | symbol)[]): number; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | a | string \| symbol \| undefined \| null | First value | | b | string \| symbol \| undefined \| null | Second value | | order | (string \| symbol)\[\] | An array of values as the predefined order | <b>Returns:</b> number ## Remarks The comparison is performed as follows: 1. If both values are included in `order`<!-- -->, they are sorted by their indexes in `order`<!-- -->. 2. The value included in `order` comes after the value not included in `order`<!-- -->. 3. If neither values are included in `order`<!-- -->, they are sorted: - symbol values come before string values - alphabetical order for two symbols or two strings