title: Understanding a custom comparator in Java
body: <p>I created a custom comparator which sorts the number of wins in descending order but im not sure how this works, can anyone explain me how this sorts according to descending order?</p>
  <pre><code>public static Comparator&lt;FootballClub&gt; sortNumOfWins = new Comparator&lt;FootballClub&gt;() {
  
      public int compare(FootballClub footballClub1, FootballClub footballClub2) {
  
          int numOfWins1 = footballClub1.getNumOfWins();
          int numOfWins2 = footballClub2.getNumOfWins();
  
          /*Returns the number of goals scored in  descending order*/
          return numOfWins2 - numOfWins1;
      }
  };
  </code></pre>