Array sorting 101

BlitzMax Forums/BlitzMax Programming/Array sorting 101

Or something like this:

SuperStrict

Type TCar
    Field color:String
    Field model:String

	Method Compare:Int(other:Object)
		Local obj:TCar	= TCar(other)
		If obj	= Self		Return 0
		If color > obj.color
			Return 1
		End If
		Return -1
	End Method

End Type

Local Car:TCar[100]

For Local n:Int = 0 To 99
    Car[n] = New TCar
    Select Rand(5)
        Case 1 Car[n].color = "Red"
        Case 2 Car[n].color = "Green"
        Case 3 Car[n].color = "Blue"
        Case 4 Car[n].color = "Purple"
        Case 5 Car[n].color = "White"
    End Select
    Print Car[n].color
Next

Print "Sorting by color...."

Car.Sort()  '<-- Obviously, this doesn't work...I need to specify the .color

For Local n:Int = 0 To 99
    Print Car[n].color
Next