title: Sorting Array of Custom Object in Java
body: <p>I am trying to sort the Project end times from smallest to largest values.</p>
  
  <p>I have created a list of custom objects called Project and am attempting to sort them based on a value returned by an accessor. I have overloaded the compare function and am receiving the error:</p>
  
  <blockquote>
    <p>The method sort(List, Comparator) in the type Collections is not applicable for the arguments (Project[], new Comparator(){})</p>
  </blockquote>
  
  <p>The code from my main is shown below, any and all help appreciated.</p>
  
  <pre><code>Collections.sort(projectList, new Comparator&lt; Project&gt;(){
  
      @Override
      public int compare(Project project1, Project project2)
      {   
         return compareProjects(project1, project2);}
      }
  );
  
  public static int compareProjects(Project project1, Project project2)
  { 
      if (project1.getEndTime() &gt; project2.getEndTime())
          return 1;
      else
          return 0;
  }
  </code></pre>
  
  <p>and my Project Class:</p>
  
  <pre><code>public Project(int projectNum, int start, int end)
  {
      this.projectNum = projectNum;
      this.start = start;
      this.end = end;
      this.length = end - start;
  }
  
  public static int getEndTime()
  {
      return end;
  }
  </code></pre>