Results 1 to 5 of 5

Thread: Sort

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    I am doing a project for election results...

    I have the candidates in an array

    dim ElectionResult(30,1)

    aCandidate = 0
    aVotes = 1


    ElectionResult(0,aCandidate) = "Gore"
    ElectionResult(1,aCandidate) = "Bush"

    etc

    if there a fast was to sort these by the number of votes they have. Is there a better way to hold the data.
    (no databases!)



    thanks

    Kurt Simons
    [I know I'm a hack but my clients don't!]

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    Sorry, you are talking to a New Hampshire Republican
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  4. #4
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    There are many algorithms to perform an array sort instead of a DB sort.
    The most popular and easiest to implement is the bubble sort algorithm, but this is not interesting if you are using a large set of elements.
    Another algorithm is the quick sort method. This evolves some more code to implement but is very quick.
    These are the most common algorithms.
    To find something in an array (which has to be sorted alphabetically), you could use the binary search algorithm.

  5. #5

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