title: How to sort a two-dimension ArrayList
body: <p>I have a two-dimension ArrayList that contains double values:</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;Double&gt;&gt; data = new ArrayList&lt;ArrayList&lt;Double&gt;&gt;(); 
  </code></pre>
  
  <p>In analogy with classic arrays , I would like to sort the "cols" of this matrix :I want to take the items having the same index in the sub ArrayLists, and then sort them. Like calling Collections.sort() for every column... 
  By rows I mean the outer level and inner level are columns.</p>
  
  <p>What is the proper way to do this?
  I thought about iterating over the matrix to invert it and then sort each row with Collections.sort() ? but maybe it's not the best solution because the matrix is about 400*7000 .</p>
  
  <p>I can't use classic arrays since the size of the matrix is unknown.</p>
  
  <p>Thanks for help.</p>