Sorting instances?

BlitzMax Forums/BlitzMax Beginners Area/Sorting instances?

Well I have been looking for the answer to this for quite some time and I havent had any luck, so I figured Ide ask here.

Basically I want to re-arrange instances within the same type. As I need proper ordering of images. In blitzbasic I know this could be achieved by doing something like this...

	Repeat
		SortChange=False
		For c.character = Each character
			c2.character = After c
			If c2 = Null Then Exit
			If c2\y < c\y Then
				Insert c2 Before c
				SortChange = True
			EndIf
		Next
	Until SortChange = False


However I have had no luck doing the same thing within Blitzmax. Any help would be appreciated.