SortList becomes slower as list is bigger..

BlitzMax Forums/BlitzMax Beginners Area/SortList becomes slower as list is bigger..

Thanks for this info. It was much faster here too, since I stumped on this typic.

For user objects, code like this can also been used (Like that one above):

Type TFileInfo
	Global sortmethod
	
	Field Album$
	Field Artist$
	Field Title$
	Field File$	
	
	Method toString:String()
		Select sortmethod
		Case 0 Return File$
		Case 1 Return Artist$+":"+Title$+":"+Album$
		Default Return Title$+":"+Artist$+":"+Album$
		EndSelect
		Return FILE$
	EndMethod
	
	Method Compare:Int(o2:Object)
		Local a:String=toString()
		Local b:String=TFileInfo(o2).toString()
		If a>b Then Return 1
		If a<b Then Return -1
		Return 0
	EndMethod
EndType


Global Info:TList=New TList ; this hold all object as TFIleInfo objects

Function sort(Sortby$)
	Select Sortby$
		Case "Files" TFileInfo.sortmethod=0
		Case "ArtistTitle" TFileInfo.sortmethod=1
		Case "TitleArtist" TFileInfo.sortmethod=2
	EndSelect
		
	Local Arr:Object[] = ListToArray(Info)
	Arr.Sort()
	Info = ListFromArray(Arr)
EndMethod


Yep, the code can been better, but it works pretty fine....