EDIT: Should have looked at the above example a bit harder, as it has the Compare() Method in there!
There's a Compare() Method that you can build into your Types that Blitz will use to sort your type with the Sort() Method. Once you have the Compare() Method as part of your Type you can use yourList.Sort() to sort it.
This Compare() Method compares an object passed to it with the current one. You can then use whatever you want to decide which is the higher/lower of the two.
Here's an example.
Sorry there's no comments, as it was just a quick program I put together to try and get my head around it. Hope it helps though.
There's a Compare() Method that you can build into your Types that Blitz will use to sort your type with the Sort() Method. Once you have the Compare() Method as part of your Type you can use yourList.Sort() to sort it.
This Compare() Method compares an object passed to it with the current one. You can then use whatever you want to decide which is the higher/lower of the two.
Here's an example.
Strict Type TPerson Field name:String Global nameList:TList Function Create(p:String) If nameList=Null Then nameList=CreateList() Local newPerson:TPerson=New TPerson nameList.AddLast(newPerson) newPerson.name=p EndFunction Function ShowList() For Local i:TPerson=EachIn nameList Print " "+i.name Next EndFunction Method Compare:Int(p:Object) Local n:TPerson=TPerson(p) If n Then If name.ToUpper() < n.name.ToUpper() Then Return -1 ElseIf name.ToUpper() > n.name.ToUpper() Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndMethod EndType RestoreData nameData Local n:String For Local i:Int=0 To 4 ReadData n TPerson.Create(n) Next Print Print "Before sorting..." TPerson.ShowList Print Print "After sorting..." TPerson.nameList.Sort TPerson.ShowList #nameData DefData "Jay","Lisa","Shona","Mum","dad"
Sorry there's no comments, as it was just a quick program I put together to try and get my head around it. Hope it helps though.