How do merge 2 distinct array of object, and then sort it?

Hello everyone,

As per title, how do I merge 2 different objects of array into one, and then sort or make a new array out of it with sorted attribute? It goes like this:

ArrayA:
Display Name: Amy , Score: 40
Display Name: James, Score: 50

ArrayB:
Display Name: Alex, Score: 60
Display Name: Lex, Score: 70

Expected New Array
ArrayC:
Display Name: Amy , Score: 40
Display Name: James, Score: 50
Display Name: Alex, Score: 60
Display Name: Lex, Score: 70

ArrayA and ArrayB objects are made up of different character class.

1 Like

Blueprint or C++?

blueprint :smile:

Without an idea of your knowledge of blueprint, guess a generic way could be:

  1. One of the characters or a third class is needed to have a reference to all actors with the data to merge.
  2. Iterate the references to append each to a new array or an existing one.
  3. swap the indexes using your favorite sorting algorithm.

And of course do all this inside a function.


If a third class is used there is also the option to get the array using an interface to avoid the include of the character class.


Here are some useful links:


Hope it helps. Let me know if you need anything specific.

1 Like

thanks for the tips! will setup a third class and see how it goes, thanks for sharing the documentation too, it’s very useful.