Find All Vectors That Hit X Physical Material

Don’t know if anybody can help me with this, but I need to find a solution for this blueprint problem I’m having:

A: I have an array of vectors, each of those vectors is generated by tracing to the terrain.
B: I also have an array of the physical materials hit by the traces performed in A

I somehow need to categorize them so I can find:

All vectors that hit X physical material. And all vectors that hit Y physical material and so on and so on.

I then need to create an array of vectors that hit X, Y or Z etc. physical material.

Huge thank you in advance to anybody who can help at all.