I have two arrays A and B. They have a many-to-many relationship. Each value of A can also appear several places in B, and each value of B can appear several places in A. Neither A nor B have unique values.
How can I get a list of all pairs of elements of A,B which share the same values?