Download

Sorting an Array according to variable.

Hello,

I am trying to sort an array of actors according to a variable placed on each actor. However for some reason only the first entry of my array is being sorted, if I remove the ‘Way Point Number’ variable and simply allow the insert node to assign indexes the entire array is copied. Below is a screen shot, any help would be great.

This shows the array not being copied.
319d6f47e2d181f8017c8fd00cbf8a3df2c4d042.png

This shows the array being copied but not being sorted.
18682b2145416e4f85a362827f2c7d3a92372de4.png

I don’t have UE open in front of me, but before you start inserting items into your sorted array, you can resize the array, use the resize node, and make it the same size as get all actors array result. Then you can set the array element using the set array element node…just remember that the array index starts at zero so depending on how you numbered the way points, you may want to insert at waypoint number-1.

Hi thanks for the reply, I did try using the resize node but then i had the problem of having lots of empty slots. In the end i decided to wire the blueprint slighty differently. But it works good now :slight_smile: thanks for the help anways.
b5ca70c1a51e4fffb8d0af3ab8e25f02b74a06fc.png