How to compare two elements in the same array

When an npc is generated they have a random id and their last name added to a struct which is then put into an array. How do I check those values against each other?

Say its 310:Gray, 262:Covics, and 689:Gray, how would I then check those against each other?

Making sure that the last names either do or don’t match and if they do then I check to make sure the numbers don’t, then from their if they do or don’t act upon them.


This isn’t amazingly efficient, but here is pseudo-code you can implement in blueprints: essentially have two loops and go through the array, checking against all other elements if any last names match with that one.

Loop from index i = 0 to ArrayLength - 1
          bHasRelatives = false
          Loop from index j = 0 to ArrayLength - 1
                if Array[i].LastName == Array[j].LastName AND i != j
                      "Last Names are Equal for element i and j"
                      bHasRelatives = true;
          if bHasRelatives == false
                 "Element i has no relatives"