another list question

BlitzMax Forums/BlitzMax Beginners Area/another list question

mudcat(Posted 2005) [#1]
here's my code.
Function  addscore()
		Local score:tscore=New tscore
		list.addlast score
		
		score.score=trock.score
		score.level=tship.level
		
		list.sort(True)
		
		If list.count()>10 list.RemoveLast score
		
	End Function


My question is-will this remove the last score or will it remove the score I just added?This is a function in my type.I have an override method for the list.sort to sort it by score.


REDi(Posted 2005) [#2]
The one you added will be at the end of the list, so it will be the one removed.

*EDIT*
I should learn to read :)

Whatever one is at the end of the list after the sort will be removed. BTW you dont pass anything to removelast, just List.removelast(), maybe that whats confusing you.


mudcat(Posted 2005) [#3]
First, the last line should be this
If list.count()>10 list.RemoveLast  'without the score


And yes,after sort,the last object in the list is deleted,not last added.(unless it's the lowest score)
Thanks,
mudcat