in reply to Remove Array Duplicates from Array of Arrays

One possibility would be to sort your AoA according to the items in your sub-arrays, and then to walk through the AoA and, for each sub-array, check whether it is equal to the previous (or next) one.

Another possibility would be to stringify the subarrays and store them in a hash (with the stringified sub-arrays as keys and sub-array references as values). The hash will automatically remove duplicates, so all you need at this point is to collect the hash values and store them in a new AoA.

Update at 8:44 UTC: I had not seen it when I started to post, but the second solution above is more or less equivalent to the solution suggested by Athanasius.

  • Comment on Re: Remove Array Duplicates from Array of Arrays