PDA

Click to See Complete Forum and Search --> : There has to be an easier way...


ToneDogg
May 30th, 2000, 01:48 AM
I'm making a highscores list for my game using files, so next time they run the program the scores are still there blah blah blah. I have 10 spots on the list and when I get score thats eligible for the list, I need to resort the data in descending order. For example...

Jonny has 10
Billy has 7
Mike has 4

Then someone gets a 8. I would have to bump Billy and Mike down and put the new guy in there... is there any shortcut to sorting an array of integers from greatest to least or least to greastest? Or do I have to use 600 if statements like I have been doing (which is really a pain :( )? Please help me if you can and thanks in advance..

- Fed up programmer :(

Fox
May 30th, 2000, 02:38 AM
The easiest way will be to sort the array always when you add a new highscore. You go trough the entries and if one is bigger than the newest highscore you move all entries after the actual one up and put the actual in. Sounds difficult but its really easy, can you tell me how you store the username and points in your program... I mean like this:
Dim Player() as String
Dim Score() as Long
-or-
Type tPlayer
Name as String
Score as Long
End Type

Dim Player() as tPlayer
...or whatever

ToneDogg
May 30th, 2000, 02:45 AM
I do it like this basically..


Private Type HighScorer
strName as String
dblScore as Double
End Type

Dim Person(1 to 10) as HighScorer


and I understand what you're saying and I'm slapping myself in the face right now, must be sleepin ;) Thanks Fox...

Fox
May 30th, 2000, 03:48 AM
*hehe* np :)