title: Java - sorting using Collections.sort()
body: <p>I have to write a method to sort both Integers and Doubles.</p>
  
  <pre><code>public ArrayList&lt;Number&gt; sortDescending(ArrayList&lt;Number&gt; al){
      Comparator&lt;Number&gt; c=Collections.reverseOrder();
      Collections.sort(al,c);
      return al;
  }
  
  public ArrayList&lt;Number&gt; sortAscending(ArrayList&lt;Number&gt; al){
      Collections.sort(al);
      return al;
  }
  </code></pre>
  
  <p>The problem is that in sortAscending, the following error occurs:</p>
  
  <blockquote>
    <p>Bound mismatch: The generic method sort(List) of type Collections is not applicable for the arguments (ArrayList). The inferred type Number is not a valid substitute for the bounded parameter &lt; T extends Comparable &lt; ? super T>></p>
  </blockquote>