unorderedPairKey
Builds a canonical, order-independent key for an unordered pair of strings — the same result
for (a, b) and (b, a). Useful for deduplicating unordered relationships (edges, matched
pairs, …) using a Set/Map keyed by string.
Available since v3.1.1
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | string | The first string |
b | string | The second string |
separator | string | Joins the two strings in the key. Defaults to `’|’` — pick a separator that cannot appear inside `a`/`b` themselves, or two distinct pairs could collide on the same key. |
Returns
Section titled “Returns”string — a and b joined by separator, in whichever of the two lexicographic orders sorts first
Examples
Section titled “Examples”Deduplicate unordered relationships in a Set
Section titled “Deduplicate unordered relationships in a Set”The same key is produced regardless of which side is passed first.
Custom separator
Section titled “Custom separator”Pick a separator that cannot appear inside the inputs to avoid collisions.
