title: How to calculate the rank of a player from a list
body: <p>Say I have following simple data structure. </p>
  
  <pre><code>public class Player {
      private Long id;
      private String name;
      private Integer scores;
  
      //getter setter
  }
  </code></pre>
  
  <p>So far so good. Now question is , how do I get what's a players rank? 
  I have another data structure for ranking, that is- </p>
  
  <pre><code>public class Ranking {
      private Integer score;
      private Integer rank;
  
      //getter/setter
  
  }
  </code></pre>
  
  <p>So I have a list of player and i want to compute a list of ranking and I would like to use java8 stream api.</p>
  
  <p>I have a service named <code>PlayerService</code> as following </p>
  
  <pre><code>public class PlayerService {
  
      @Autowired
      private PlayerRepository playerRepository;
  
  
      public List&lt;Ranking&gt; findAllRanking(Long limit) {
          List&lt;Player&gt; players = playerRepository.findAll();
  
         // calculation 
  
          return null;
      }
  </code></pre>
  
  <p>The calculation is simple, whoever has most score has most ranking. </p>
  
  <p>If I have <code>5,7,8,9,3</code> scores then ranking would be </p>
  
  <pre><code>rank score 
    1   9
    2   8 
    3   7
    4   5
    5   3
  </code></pre>
  
  <p>Any help would be appreciated. </p>