I've started the Hack and Slash tutorial on BurgzergArcade.
It is shown in c# but i've been using javascript and I now need to sort an array based on another.
One array is a list of GameObjects and the other is a list of float variables, which are the distance between each gameobject and the character.
What I need to do is sort the distances in ascending order and also apply the same sort to the gameobject.
I'd use a bubble sort, since it's easy to program. Unity has built-in sort, but only a basic one that sorts the items in the array with regard to each other.
PS: This code is untested, so it may not just work out of the box. But I hope it gets across the idea.
@almo
Can I say that I have just spent the last 2 hours laboring over how to get this working. I tried every goddamn bubble sort algorithm I knew to man, but because my knowledge is mostly python it just all screwed up. You absolutely saved my life here man, thank you so much for this. I know this was posted a very long time ago for you, but I still need to thank you for this regardless.