Implement competition ranking strategy. Refactor redundant ranking code. Add unit test for ranking.