0 votes

So I've got an array of values with an identifying node, so [5, nodeA][7, nodeB][4, nodeC] and so on. I have corresponding visual boxes that show the number + node name in each box but at the moment I just update the values in each box when the array gets sorted. I modify the values in the array, then sort it, then update the boxes. What's a good way to move the boxes around after sorting?
At the moment, I have a previous, current, and next index on the visual nodes. The visual nodes have the current index match with the array. After changing and sorting the array, I go through the sorted array and find the matches in the visual nodes and update the previous index to have the current index, and current index having the matched index. And in theory, I would move the visual boxes to the current index position from the previous index. It doesn't feel efficient, but I don't know how I would incorporate this in the actual array sorting.

in Engine by (37 points)

1 Answer

0 votes

Wow that is complicated, I don't get it :). Why didn't You use dictionary isntead of array ? It sounds like it would be sollution to any of these kinds of problems

by (6,519 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.