I have points assigned to each player like this:
player1 = 20 , player2 = 30, player3 = 50, player4 = 10, player5 = 25 and so on.
and these points change as they score more points. What i am trying to do is if player2 looks at his page he should see which player of all has highest score, where he is in all players and who has the lowest score? What is the best way to do this in php? So it will show something like this:
Highest Scorer Player2 Lowest Score
player3 you are 2nd highest out of 5 players player4
$minScore and $minScorePlayer is the lowest player
$maxScore and $maxScorePlayer is the highest player
$thisScore and $thisPlayer is the player you are interested in
$higherCount is the number of players with higher score than your player
The above has a complexity of O(n)
The sorting solution has a complexity of O(n * logn )