Results 1 to 4 of 4

Thread: There has to be an easier way...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Rochester, NY
    Posts
    6

    Angry

    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

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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:
    Code:
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Rochester, NY
    Posts
    6
    I do it like this basically..

    Code:
    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...

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    *hehe* np

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width