Filter List: Unique | ARRAY_UNIQUE

Syntax

ARRAY_UNIQUE( [value] )

Parameters

value
An ARRAY to filter.

Return Value

Returns an ARRAY of items consisting of all values in VALUE but with duplicates removed.

Description

Get unique items in an ARRAY. If multiple items in the ARRAY are the same value, the first one found is kept and the rest discarded. Equality is checked based on the same rules as the EQUAL operation.

Examples

ARRAY_UNIQUE(null) # returns []
# VALUE is [
#   '1', '2', 1, 1, 2, '3', '3'
# ]
ARRAY_UNIQUE(VALUE)
# returns [
#   '1', '2', 1, 2, '3'
# ]
ARRAY values are compared structurally.
# VALUE is [
#   [1, 2, 3],
#   [1, 2, 4],
#   [1, 2, 3],
#   [1, 2, 3, 4]
# ]
ARRAY_UNIQUE(VALUE)
# returns [
#   [1, 2, 3],
#   [1, 2, 4],
#   [1, 2, 3, 4]
# ]
MAP values are also compared structurally.
# VALUE is [
#   ["id" => 1, "fruit" => "apple"]
#   ["id" => 2, "fruit" => "banana"],
#   ["id" => 1, "fruit" => "apple"],
#   ["id" => 3, "fruit" => "banana"]
# ]
ARRAY_UNIQUE(VALUE)
# returns [
#   ["id" => 1, "fruit" => "apple"]
#   ["id" => 2, "fruit" => "banana"],
#   ["id" => 3, "fruit" => "banana"]
# ]