I am retrieving data from mysql whick=h I need to rank from highest to lowest. I am thinking of retreaving it as a single array by using a user-defined function. The ranking becomes tricky if there are duplicates. Let me illustrate with an example;
89, 79, 79, 79, 78, 54, 50, 41, 41, 38. The above would be ranked as;
89 - 1, 79 -2, 79 - 2, 79 - 2, 78 - 5, 54 - 6, 50 - 7, 41 - 8, 41 - 8, 38 - 10
it becomes more tricky if a tie occurs at the end, such as;
89 - 1, 79 -2, 79 - 2, 79 - 2, 78 - 5, 54 - 6, 50 - 7, 41 - 8, 38 - 10, 38 - 10
So as you can see, if there is a tie, the numbers tying are assigned the number, and the next position is skipped to preserve postions because at the end of the day, the number of positions should equal the number of scores, as illustrated above.
My question is, is it possible to use PHP to that kind of ranking assuming we have the scores as an array? Can someone help me write a function that can do this and which is robust enough to handle duplicate values in the manner illustrated above?
Could it be that PHP CANNOT do this kind of manipulation?