Sorting Float Array Numerically?

Hey all,

what would be the best way to tackle this? I have an array of floats that need to get sorted into descending order, but I’m a bit stumped on doing this within blueprint rather than C++.

Hi ianoreo,

check out the following blueprint graph

I iterate over the array as long as there are items in it. On each iteration, I get the largest value of the array, add it to my new array and remove it from the old one. That way the new array hold all values in descending order. It you would like to have it ascending you would need to use the min function.

1 Like

Perfect! Thanks, didn’t even know about that node.

No problem, glad I could help :slight_smile: Please mark your question as answered (I got a mail that you already accepted my answer, but well seems like it isn’t marked as accepted), thank you :wink:

I have a struct for 2 values (integer and string) … it is a struct to save highscore (int) and player’s name

Is there a way to add a new highscore and sort this way? but i can’t use “Max of array float” on my struct array, because it’s not a float array.

You should create a new entry for this question.

foreach loop through your struct array, rip out the integers into a new array, sort that array just like the example above, but every time you move an element from the old integer array into the new integer array, you should also move the corresponding element from your old struct array into the new struct array.

something like this NewWidgetBlueprint (217 kb) закачан 3 марта 2017 г. Joxi

but remove index of temp array need to be first instead temp float array.
I spent a hour to try figure out my mistake)