title: How to add comparator to inner class?
body: <pre><code>    public class Prerequisites {
  
          private class Course implements Comparator&lt;Course&gt; {
              public String name;
              public LinkedList&lt;Course&gt; requiredFor;
              public LinkedList&lt;Course&gt; prerequisites;
  
              Course(String name) {
                  requiredFor = new LinkedList&lt;Course&gt;();
                  prerequisites = new LinkedList&lt;Course&gt;();
                  this.name = name;
              }
  
              @Override
              public int compare(Course c0, Course c1) {
                  Pattern p = Pattern.compile("[A-Z]*");
                  Matcher matcher0 = p.matcher(c0.name);
                  Matcher matcher1 = p.matcher(c1.name);
                  matcher0.find();
                  matcher1.find();
                  int courseNumber0 = Integer.parseInt(c0.name.substring(matcher0.end(),c0.name.length()));
                  int courseNumber1 = Integer.parseInt(c1.name.substring(matcher1.end(),c1.name.length()));
                  if(courseNumber0 &gt; courseNumber1) {
                      return 1;
                  }
                  else if(courseNumber0 &lt; courseNumber1) {
                      return -1;
                  }
                  else {
                      return matcher0.group().compareTo(matcher1.group());
                  }
              }
  
              @Override
              public String toString(){
                  return this.name;
              }
          }
      public void compare(String args[]) {
          Course c0 = new Course("CSE110");
          Course c1 = new Course("DSE110");
          LinkedList&lt;Course&gt; courses = new LinkedList&lt;Course&gt;();
          courses.add(c0);
          courses.add(c1);
          **Collections.sort(courses);** //gives compiler error
  
      }
   }
  </code></pre>
  
  <p>Why adding Collections.sort() for this inner class is not working ? I am not able to figure that out from the compiler error.</p>