🔄 Checks if two arrays are equivalent, regardless of element order.

Info

It performs deep comparisons using the isEql function.

Info

It also supports comparing sparse arrays.

Syntax

TypeScript
import { isUnorderedEqual } from '@opentf/std';

isUnorderedEqual(arr1: unknown[], arr2: unknown[]): boolean

Parameters

  • arr1: The first array to compare.

  • arr2: The second array to compare.

Returns

true if the arrays contain the same elements in any order, false otherwise.

Examples

TypeScript
isUnorderedEqual([1, 3, 2], [2, 1, 3]) //=> true

isUnorderedEqual([1, 3, 2], [2, 1, 5]) //=> false

isUnorderedEqual([{ a: 1 }, { b: 2 }], [{ b: 2 }, { a: 1 }]) //=> true
Last updated on
Edit this page