Hey all. I’ve attempted to implement a bubble sort function using blueprint. The end goal is to sort an array of actors according to a variable inherent to each actor of the class called Agility in order to establish a turn order. I’m running into some difficulties and could use a helping hand.
The level I’m using to test the function has six children of the class placed into it: “Protagonist”, “Redman”, “Blugirl”, and three “EvilCubes”. Using The Get All Actors of Class Node and then printing the contents of the array results in this output:
“Protagonist” has a default Agility of 7, “Redman” has a default Agility of 5, “Blugirl” has 6, and the three “Evil Cubes” each have 3. Knowing this, if I run the Sort function and then print the output, the order should be Protagonist, Blugirl, Redman, Evil Cube, Evil Cube, Evil Cube. However, the actual output looks like:
It’s mostly correct, but Redman and Blugirl are out of the expected order.
Additionally, this error message is produced in the message log when running the code:
The following is my sort function in its current state:
I just have no idea where I went wrong. Anyone can recommend a fix for me?