title: Sorting a generic ArrayList of ArrayLists
body: <p>I have a list of points. I represented this as an ArrayList of ArrayLists. I'm trying to use generics so that the list can store Integers, Floats, etc. and treat them the same. So I have:</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;? extends Number&gt;&gt;. 
  </code></pre>
  
  <p>I need to compare these lists based on one element in each inner list.</p>
  
  <p>So to do that I wrote a custom Comparator that I'm using in Collections.sort</p>
  
  <p>The Comparator looks like:</p>
  
  <pre><code>int compare(ArrayList&lt;? extends Number&gt; a, ArrayList&lt;? extends Number&gt; b )
  {
      return a.get(index).compareTo(b.get(index))
  }
  </code></pre>
  
  <p>This doesn't compile of course. The compiler complains that there is no compareTo method for the wildcard class.</p>
  
  <p>Is what I'm trying to do even possible?</p>