# Normalise the data. @$_ = sort { $a <=> $b } @$_ for @AoD; # Filter out duplicates. my %seen; @AoD = grep !$seen{ join(',', @$_) }++, @AoD;