title: why we need to return 0 when Comparator.compare become equal
body: <p>I understand that when implement compare method of Comparator interface we need to return</p>
  
  <ul>
  <li>+1 if o1 > o2</li>
  <li>-1 if o1 &lt; o2</li>
  <li>0 if o1 == o2</li>
  </ul>
  
  <p>my question is why we need to return 0 when both equal? what is the use case or where it being used? 
  if we considered sorting when o2 greater than to o1 or o2 equal to o1 does not change it place. 
  can anyone come explain practical use case for this?</p>
  
  <p>Java documentation says </p>
  
  <blockquote>
    <blockquote>
      <p>Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.</p>
    </blockquote>
  </blockquote>
  
  <p>Does this mean return -1 or return 0 has same impact? </p>
  
  <blockquote>
    <blockquote>
      <p>zero, or a positive integer </p>
    </blockquote>
  </blockquote>
  
  <pre class="lang-java prettyprint-override"><code> @Override
      public int compare(Test f1, Test f2) {
          if (f1.getId() &gt; f2.getId()) {
              return 1;
          } else if (f1.getId() &lt; f2.getId()) {
              return -1;
          } else {
              return 0;
          }
  
      }
  </code></pre>