Algorithm for the classification of scores

I have a array T[1..N] of integer (Delphi XE2)
It contains the scores obtained by players (player 1 => T[1], etc...)
I need to have the final classification of them in array C[1..N] of integer;
So if player p has the highest score, C[p] value is 1 (first) etc...
In case of several same score, then same classification
Exampe T = (1,30,2,1,15,6,15)
C = (5,1,5,2,4,2)
What is the "best" code to achieve this ?
LVL 1
LeTayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

d-glitchCommented:
Did you mean:
     Example T = (1, 30, 2, 1, 15, 6, 15)  ==>  C = (6 ,1 ,5 ,6 ,2 ,4 , 2)

If so, then you just have to sort    ( 1, T[1]), (2, T[2],  ... (n, T[n])    max to min by the second element and output the first element in new order resolving ties.
0
LeTayAuthor Commented:
Well, problem raises when several scores are identical ...
In my example (you corrected it, thanks), score 15 is twice the second
0
LeTayAuthor Commented:
I think I found by myself 8
  for I := 1 to N do C[I] := 1;
  for I := 1 to N do
    for K  := (I + 1) to N do
      begin
          if (T[I] < T[K])
            then C[I] := C[I] + 1
            else if (T[I] > T[K])
              then C[K] := C[K] + 1;
      end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Algorithms

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.