Has anyone here had to rank players playing against each other before?
Player1 might play against Player2 today and tomorrow Player1 might not play at all, but Player2 might play against Player3 - so not all players will be playing at the same time, some might play many more games than other.
Which player should be ranked highest and what formula did you use to make that decision?
Also, how would your scoring system encourage weaker players to play against stronger players and stronger players to want to play against the weaker players.
I have some ideas, but would like some input from Hashnoders
Update - rating systems so far:
And in case you need to calculate these things without a computer, by hand, there's a simplified version of ELO called the Harkness Rating System, you start with a rating of 1200 and then based on the difference in rating between player1 and player2, you transfer points according to this table:

Sai Kishore Komanduri
Engineering an eGovernance Product | Hashnode Alumnus | I love pixel art
Maybe you could take a look at implementations of the ELO ranking method, which takes into account the rank of both players before ranking (meaning Player1 will gain less points when winning against Player3 than Player2).
(PHP / SQL)
(1 way to do this, I've never actually calculated player rank, but this came to mind)
player_stats
-- player_id
-- wins (int)
player_id | wins
1 8
2 99
3 1
4 40
// find who the current player should play against
// +/- 10 wins
"select * from `player_stats` where wins Between ($current_user_wins - 10) AND ($current_user_wins + 10) limit 1"
"Also, how would your scoring system encourage weaker players to play against stronger players and stronger players to want to play against the weaker players."
// find a random opponent
// from a larger pool
// + / - 50 wins for a bigger pool
"select * from `player_stats` where wins Between ($current_user_wins - 50) AND ($current_user_wins + 50) order by RAND() limit 1"
(Be sure to mind any negative values and results with 0 rows)
For overall rank, I think I'd find the player with the most games played or store it somewhere and calculate each players rank out of that - ie: if the most games played by any given player was 100, player 2 would be at the top, player 3 at the bottom and player 4 somewhere in the middle
Check out Elo Rating System, Jan: https://www.wikiwand.com/en/Elo_rating_system. It details methods to rate players of a competitive game in to higher/lower rank buckets, based on their skill levels. It all started with chess. A lot of online competitive games now-a-days use this sort of rating, to rank their players.
Alternatively you can also look into this: evanmiller.org/how-not-to-sort-by-average-rating.…. Evan details a way to correctly sort a product according to user ratings, using statistical sampling; and does it "correctly" even in the case when the no. of ratings between two products are disparately different. You can adapt this model for rating your players; where the no. of ratings would be analogous to the number of games played, and a positive rating is a win, a negative one, a loss.