title: How to sort data in a CSV file using a particular field in Java?
body: <p>I want to read a CSV file in Java and sort it using a particular column. My CSV file looks like this:</p>
  
  <pre><code> ABC,DEF,11,GHI....
   JKL,MNO,10,PQR....
   STU,VWX,12,XYZ....
  </code></pre>
  
  <p>Considering I want to sort it using the third column, my output should look like:</p>
  
  <pre><code> JKL,MNO,10,PQR....
   ABC,DEF,11,GHI....
   STU,VWX,12,XYZ....
  </code></pre>
  
  <p>After some research on what data structure to use to hold the data of CSV, people here suggested to use Map data structure with Integer and List as key and value pairs <a href="https://stackoverflow.com/questions/21642548/data-structure-for-holding-the-content-of-a-parsed-csv-file">in this question</a>:</p>
  
  <pre><code> Map&lt;Integer, List&lt;String&gt;&gt;
   where the value, List&lt;String&gt; = {[ABC,DEF,11,GHI....], [JKL,MNO,10,PQR....],[STU,VWX,12,XYZ....]...}
   And the key will be an auto-incremented integer starting from 0.
  </code></pre>
  
  <p>So could anyone please suggest a way to sort this Map using an element in the 'List' in Java? Also if you think this choice of data structure is bad, please feel free to suggest an easier data structure to do this.</p>
  
  <p>Thank you.</p>