title: Getting error The method sort(List<T>, Comparator<? super T>) in the type Collections is not applicable for the arguments
body: <p>I want to sort a collection on basis of enum order, but getting error :
  The method sort(List, Comparator&lt;? super T&gt;) in the type Collections is not applicable for the arguments</p>
  <p>The classes are as following
  This is the enum class on whos order I need the sorting</p>
  <pre><code>package com;
  
  import java.util.Comparator;
  
  public enum MyLink {
  
      CREATE_LOGIN(&quot;My Create login&quot; ,0),
      LISTEN_NOW(&quot;My Listen now&quot;, 1),
      FREE_PREVIEW (&quot;My FREE PREVIEW&quot;, 2);
  
      private final String value;
      
      private final int order;
  
      
      
      private MyLink(String value, int order) {
          this.value = value;
          this.order = order;
      }
  
      public String getValue(){
          return value; 
      }
      
      public int getOrder() {
          return order;
      }
  
      public static Comparator&lt;MyLink&gt; orderComparator = new Comparator&lt;MyLink&gt;() {
          public int compare(MyLink ctaLink1, MyLink ctaLink2) {
            return ctaLink1.getOrder() - ctaLink2.getOrder();
          }
        };
      
  }
  </code></pre>
  <p>This class conatins the MyLink Order.</p>
  <p>package com
  public class Profile {</p>
  <pre><code>private MyLink eligibilityType;
  
  private String id;
  
  public MyLink getEligibilityType() {
      return eligibilityType;
  }
  
  public void setEligibilityType(MyLink eligibilityType) {
      this.eligibilityType = eligibilityType;
  }
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  @Override
  public String toString() {
      return &quot;Profile [eligibilityType=&quot; + eligibilityType + &quot;, id=&quot; + id + &quot;]&quot;;
  }
  </code></pre>
  <p>}</p>
  <p>Here In TestTrial I am setting the list and calling the collections.sort mwthod which is throwing error Getting error The method sort(List, Comparator&lt;? super T&gt;) in the type Collections is not applicable for the arguments</p>
  <pre><code>package com;
      import java.util.List;
      import java.util.ArrayList;
      import java.util.Collections;
      import java.util.*;
      
      
      public class TestTrial {
      
          public static void main(String[] args) {
              System.out.println(&quot;hello&quot;);
              List&lt;Profile&gt; prolifes = new ArrayList&lt;Profile&gt;();
              Profile n1 = new Profile();
              n1.setId(&quot;2&quot;);
              n1.setEligibilityType(MyLink.FREE_PREVIEW);
              
              prolifes.add(n1);
              
              
              Profile n2 = new Profile();
              n2.setId(&quot;1&quot;);
              n2.setEligibilityType(MyLink.CREATE_LOGIN);     
              prolifes.add(n2);
              
              Profile n3 = new Profile();
              n3.setId(&quot;3&quot;);
              n3.setEligibilityType(MyLink.LISTEN_NOW);       
              prolifes.add(n3);
              
              for(Profile n : prolifes) {
                  System.out.println(&quot;n::&quot; + n );
              }
              
              //Collections.sort(nonPiiSubscriptions, CTALink.orderComparator);
              //nonPiiSubscriptions.sort(Comparator.comparing(nonPiiSubscriptions::name));
      
      
              Collections.sort(prolifes, new Comparator&lt;MyLink&gt;()
              {
                  @Override
                  public int compare(MyLink ctaLink1,MyLink ctaLink2)
                  {
                      return ctaLink1.getOrder() - ctaLink2.getOrder();
                  }
              });
      
              
              
          }
      
      
      }
  </code></pre>
  <p>Please suggest how I can sort the list of profile on enum order</p>