|Topic was automatically imported from the old Question2Answer platform.
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.