title: BlueJ - 'no suitable method found' for sort method
body: <p>I'm using <em>BlueJ</em> for a project. Here is my code:</p>
  
  <pre><code>import javax.swing.*;`
  import java.awt.*;
  import java.util.Collection;
  import java.util.Collections;
  import java.awt.event.*;
  import java.util.*;
  import java.util.List;
  
  public class SongSorter extends JFrame
  {
      private JPanel main, header, buttons1, buttons2, labels, texts, SongPanel;
      private JTextField Title, Artist, Album, Year;
      private JLabel credits, title, artist, album, year;
      private JButton add, shuffle, sortTitle, sortArtist, sortAlbum, sortYear;
      private JTextArea RecordsText;
      private Song s;
      private List&lt;Song&gt; playlist;
  
  public SongSorter()
  {
      Container c = this.getContentPane();
      c.setLayout( new FlowLayout() );
      c.setBackground( Color.BLACK );
  
      main = new JPanel( new BorderLayout() );
      main.setSize( 200, 200 );
      c.add( main);
  
      // for buttons
      header = new JPanel( new GridLayout(4, 1) );
      main.add( header, "North" );
  
      buttons1 = new JPanel( new FlowLayout() );
      header.add( buttons1 );
  
      add = new JButton( "Add" );
      shuffle = new JButton( "Shuffle" );
  
      buttons1.add( add );
      buttons1.add( shuffle );
  
      buttons2 = new JPanel( new FlowLayout() );
      header.add( buttons2 );
  
      sortTitle = new JButton( "Title" );
      sortArtist = new JButton( "Artist" );
      sortAlbum = new JButton( "Album" );
      sortYear = new JButton( "Year" );
  
      buttons2.add( sortTitle );
      buttons2.add( sortArtist );
      buttons2.add( sortAlbum );
      buttons2.add( sortYear );
  
      texts = new JPanel( new FlowLayout() );
      header.add( texts );
  
      Title = new JTextField( "Title", 10 );
      Artist = new JTextField( "Artist", 10 );
      Album = new JTextField( "Album", 10 );
      Year = new JTextField( "Year", 10 );
  
      title = new JLabel("Title: ");
      artist = new JLabel("Artist: ");
      album = new JLabel("Album: ");
      year = new JLabel("Year: ");
  
      texts.add( title );
      texts.add( Title );
      texts.add( artist );
      texts.add( Artist );
      texts.add( album );
      texts.add( Album );
      texts.add( year );
      texts.add( Year );
  
      // where the user will see the record of songs listed
      SongPanel = new JPanel( new GridLayout(1, 1) );
      main.add( SongPanel, "Center" );
      SongPanel.setSize(100, 100);
  
      RecordsText = new JTextArea();
      RecordsText.setWrapStyleWord( true );
      RecordsText.setLineWrap( true );
      RecordsText.setTabSize( 100 );
      SongPanel.add( RecordsText );
  
      playlist = new ArrayList&lt;Song&gt;();
  
      // sorting comparators
      final SongByTitle t = new SongByTitle();
      final SongByArtist a = new SongByArtist();
      final SongByAlbum b = new SongByAlbum();
      final SongByYear y = new SongByYear();
  
      // time for buttons and shit
      // add and shuffle
      add.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  String t = Title.getText();
                  String a = Artist.getText();
                  String b = Album.getText();
                  int y = Integer.parseInt( Year.getText() );
  
                  s = new Song(t, a, b, y);
                  playlist.add( s );
  
                  RecordsText.append( s.print() );
              }
          }
      );
  
      shuffle.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  Collections.shuffle( playlist );
                  RecordsText.setText( playlist.toString() );
              }
          } );
  
      // sorting buttons
      sortTitle.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  Collections.sort( playlist, t );
                  RecordsText.setText( playlist.toString() );
              }
          } );
  
      sortArtist.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  Collections.sort( playlist, a );
                  RecordsText.setText( playlist.toString() );
              }
          } );
  
      sortAlbum.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  Collections.sort( playlist, b );
                  RecordsText.setText( playlist.toString() );
              }
          } );
  
      sortYear.addActionListener( new ActionListener()
          {
              public void actionPerformed( ActionEvent ae )
              {
                  Collections.sort( playlist, y );
                  RecordsText.setText( playlist.toString() );
              }
          } );
      }
  }
  
  class SongByTitle implements Comparator&lt;Song&gt;
      {
          public int compare( Song a, Song b )
          {
              return a.getTitle().compareTo( b.getTitle() );
          }
      }
  
      class SongByArtist implements Comparator&lt;Song&gt;
      {
          public int compare( Song a, Song b )
          {
              return a.getArtist().compareTo( b.getArtist() );
          }
      }
  
      class SongByAlbum implements Comparator&lt;Song&gt;
      {
          public int compare( Song a, Song b )
          {
              return a.getAlbum().compareTo( b.getAlbum() );
          }
      }
  
      class SongByYear implements Comparator&lt;Song&gt;
      {
          public int compare( Song a, Song b )
          {
              if( a.getYear() &lt; b.getYear() ) return -1;
              else if(a.getYear() &gt; b.getYear() ) return 1;
              else return 0;
          }
      }
  </code></pre>
  
  <p>and I keep getting this error:</p>
  
  <pre><code>no suitable method found for sort(java.util.List&lt;Song&gt;, SongByTitle)
      method java.util.Collections.&lt;T&gt;sort(java.util.List&lt;T&gt;,java.util.Comparator&lt;? super T&gt;) is not applicable
       (no instance(s) of type variable(s) T exist so that argument type SongByTitle conforms to formal parameter type java.util.Comparator&lt;? super T&gt;)
      method java.util.Collections.&lt;T&gt;sort(java.util.List&lt;T&gt;) is not applicable
       (cannot instantiate from arguments because actual and formal argument lists differ in length)
  </code></pre>
  
  <p>I've been searching for an hour or so online on what I can do to fix this; I've changed my playlist from an ArrayList to a List only, I've tried to just call the Comparator inside the sort() method itself - I feel like I've tried everything and yet it STILL doesn't work.</p>
  
  <p>Whenever I try to compile it, it always highlights my '.sort' part. I feel like I've run out of places to go to for asking for advice regarding the matter. </p>
  
  <p>I also read the other questions here on stackoverflow. I've been surfing through these pages for an hour now, and still no clue. I don't know where I got it wrong. It seems fine by me. </p>
  
  <p>Whoever can help regarding this will be fully appreciated. (You'll help me sleep earlier once I get this done. XD)</p>
  
  <p>-- </p>
  
  <p>oh, just in case, here's the other classes in the program.</p>
  
  <p><strong>Comparator interface</strong></p>
  
  <pre><code>public interface Comparator&lt;Song&gt; 
  {
      int compare( Song a, Song b );
  }
  </code></pre>
  
  <p><strong>Song class</strong></p>
  
  <pre><code>public class Song
  {
      String title, artist, album;
      int year;
  
  public Song(String t, String a, String b, int y)
  {
      title = t;
      artist = a;
      album = b;
      year = y;
  }
  
  public String getTitle()
  {
      return title;
  }
  
  public String getArtist()
  {
      return artist;
  }
  
  public String getAlbum()
  {
      return album;
  }
  
  public int getYear()
  {
      return year;
  }
  
  public String print()
  {
      String t = this.getTitle();
      String a = this.getArtist();
      String b = this.getAlbum();
      int y = this.getYear();
  
      String song = t + 
          " by " + a + "; Album: " + b + ", " + y + "\n";
      return song;
  }
  
  @Override
  public String toString()
  {
      return title + " by " + artist 
         + "; Album: " + album + ", " + year + "\n";
  }
  }
  </code></pre>
  
  <p><strong>Runner class</strong></p>
  
  <pre><code>public class SongRunner
  {
      public static void main( String[] args )
      {
          JFrame f = new SongSorter();
          f.setSize( 200, 200 );
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          f.setVisible( true );
          f.setResizable( false );
      }
  }
  </code></pre>