Why IS this code WORKING?

BlitzMax Forums/BlitzMax Beginners Area/Why IS this code WORKING?

Ryan Burnside(Posted 2007) [#1]
This question may seem odd but my code now works via tinkering around. It actually sorts my highscore objects by their score values WITHOUT me telling them to. Why is this? It's great that it works but things like this often have very iffy results...




TaskMaster(Posted 2007) [#2]
I see a Sortlist in there?


TaskMaster(Posted 2007) [#3]
Your Method Compare is screwy though. Just suppose to return 1 for Yes and -1 for No.

Method Compare(otherObject:Object)
If otherObject.score>score Return 1
Return -1
End Method


ziggy(Posted 2007) [#4]
@Ryan Burnside:Just in case your question is how sortlist knows how to sort your list:

The method compare is suposed to be implemented for 'sortable' types. In your compare method you're telling how to sort your scores, as the comparison is being made by the score field. Change the score field comparison by a "player" field comparison, and you'll get the socres sorted by player's name. Isn't it great?


Ryan Burnside(Posted 2007) [#5]
Thanks you for all your help.