Skip to content

Help on Ranking

Nicholas

Asked Oct 9, 2005, 8:39 PM EDT4 answers
Share
LinkedInX
Hi, my name is Nicholas I'm current new to programming and I'm working on a scoring program so it can help my friend record the score with ease.
 
The link below is an example on how the scoring works. 
http://img.photobucket.com/albums/v684/nictan/example.jpg

 
My question to it is
how can you do a Ranking system?
How can you do a prioritizing as in if the best of 3 scores are the same.
They will do a comparing with the score1 first if they are the same will proceed to the next score2 till score4
If all 4 scores are the same user can input who won that draw at the end of entering the score. 

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    you just need a proitised sort routine

    public void Sort(bool largeToSmall){
       object obj;
       for(int i=1;i<items.Count;i++){
          bool test = false;
          if(largeToSmall)
             test = ((IComparable)items[i]).CompareTo((IComparable)items[i-1])>0;
          else
             test = ((IComparable)items[i]).CompareTo((IComparable)items[i-1])<0;
          if(test){
             obj = items[i];
             items[i] = items[i-1];
             items[i-1] = obj;
             i-=2;
          }
          if(i<0)i=0
       }
    }

    and you compare method says something like

    public int CompareTo(object obj){
       YourClass class = (YourClass)obj;
       if(class.TotalScore<this.TotalScore) return 1;
       else if(class.TotalScore>this.TotalScore) return -1;
       else{
          if(class.Score1<this.Score1) return 1;
          else if(class.Score1>this.Score1) return -1;
          else{
             <<SAME FOR SCORE 2,3,4,5,6,7,... Final else just reads return 0>>
          }
       }
    }


    I've written the second bit on the fly so it's might have mistake (like having the < & > the wrong way round but generaly it should work

    0
  • 0
    You need to place the scores into an array and then sort the array, using:

    Array.Sort(arrayname);
    0
  • 0
    wont work he wants to sort by multiple values

    eg in an address book if 2 people have the surname Smith the given name is used to determine the order in which they are shown
    0
  • 0
    i don quite understand it... maybe you could explain what those lines does???
    0