using unnest and distinct example:
t=# create or replace function so62(a1 anyarray,a2 anyarray) returns boolean as
$$
declare
_r boolean := false;
_a text;
begin
with p as (select distinct unnest(a1) order by 1) select array_agg(unnest) into _a from p;
with p as (select distinct unnest(a2) order by 1) select array_agg(unnest)::text = _a into _r from p;
return _r;
end;
$$ language plpgsql;
CREATE FUNCTION
(function updated following @poz notice that it would require two except for comparison)
test:
t=# with c as (
select '{1,null,2,2}'::int[] a1,'{2,1,null}'::int[] a2
)
select a1 @> a2, a2 @> a1,so62(a1,a2)
from c;
?column? | ?column? | so62
----------+----------+------
f | f | t
(1 row)
in this example @> and <@ do not work at all.
Also read Compare arrays for equality, ignoring order of elements
unnestand work with set, this could be faster or slower, depending on your data, conditions and indexes.