Sorting a lift by a field in ascending order

BlitzMax Forums/BlitzMax Beginners Area/Sorting a lift by a field in ascending order

Global List:TList = CreateList()

Type mytype

	Field value:Int
	
	Function create:mytype(val:Int)
		Local t:mytype = New mytype
		t.value = val
		ListAddLast(List,t)
		Return t
	End Function
	
	Method Compare:Int(This:Object)
		Return Value - mytype(This).value
	EndMethod
	
End Type

mytype.Create(12)
mytype.Create(6)
mytype.Create(28)
List.Sort(True)

For i:mytype = EachIn list
	Print i.value
Next