Infinite Loop Detected with only for loops

Hi,
I’m trying to sort an array in unreal engine 5 and I get an infinite loop detected error everytime I run my code. I don’t understand why there is an infinite loop :

Thanks in advance for your help,
Tchoupizbouby

I can’t see anything in particular there, but what you need to know about arrays in blueprint, is you can’t remove/switch indexes while you’re trying to loop over the array. Everything just ends up in a big mess.

What works much better is to work with two arrays. Take items from array A into B and sort them as you go.

1 Like

Thank you very much !

2 Likes

I absolutely cannot make any sense out of this. I think you need to be using a data structure more suited to whatever it is you’re trying to achieve.