title: Collections.Sort an ArrayList in java
body: <p>I use this function in java:</p>
  
  <pre><code>Collections.sort(an Arraylist, new CustomComparator);
  </code></pre>
  
  <p>The compare method in CustomComparator class will return an int. What this means to the sort procedure? what's the number of this value and how will affect the sorting procedure?</p>
  
  <p>More specifically i want in compare method to compare two values. Here is my code:</p>
  
  <pre><code>    import java.util.Comparator;
  
      public abstract class CustomComparator implements Comparator&lt;HLine&gt; {
          @Override
          public int compare(HLine hl1, HLine hl2) {
              return hl1.y &lt; hl2.y;
          }
      } 
  </code></pre>
  
  <p>and i call for sorting:</p>
  
  <pre><code>    Collections.sort(hlines, new comparator());
  </code></pre>
  
  <p>hlines is an Arraylist of a object's with a Point and two doubles. I want to compare the second double in two object's.</p>