Shuffling an Int Array

BlitzMax Forums/BlitzMax Beginners Area/Shuffling an Int Array

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Found much less resource-demanding and more convenient algo (and still more-less "clean"):

SuperStrict
SeedRnd MilliSecs()

Local Nums%[] = [ 1, 1, 2, 3, 5, 8, 13, 21, 34 ]
RandomizeArray( Nums )
PrintArray Nums

Function RandomizeArray( Array%[] )
	Local ArrayLength% = Array.Dimensions()[ 0 ]
	For Local N% = 0 To ArrayLength% - 2
		Local M% = Rand( N%, ArrayLength% - 1)
		Local Z% = Array%[ N% ]
		Array%[ N% ] = Array%[ M% ]
		Array%[ M% ] = Z%
	Next
End Function

Function PrintArray( Array%[] )
	Local Text$
	For Local N% = 0 To Array.Dimensions()[ 0 ] - 1
		Text$ :+ Array%[ N% ] + ", "
	Next
	DebugLog Text$
End Function