title: sorting a csv file according to column in C++
body: <p>I been given a task to sort a csv file depending on the users input</p>
  
  <p>The data looks like this:</p>
  
  <pre><code>California,USA,65,76,65,67
  Paris,France,78,65,97,87
  Tokyo,Japan,56,78,67,87
  New York,USA,54,65,67,44,67
  </code></pre>
  
  <p>Or basically the column represents </p>
  
  <pre><code>City,Country,q1 average temperature, q2 average temperature, q3 , q4
  </code></pre>
  
  <p>my task is to sort this according to columns:  city as column 1, country column 2 , and so on... depending on the user input.</p>
  
  <p>so if the user input is <code>1dec</code> that means it will be sort by 1st column(alphabetically in this case) and prints the sorted data</p>
  
  <p>for the example above it would print as:</p>
  
  <pre><code>Tokyo,Japan,56,78,67,87
  Paris,France,78,65,97,87
  New York,USA,65,67,67,44,67
  California,USA,65,76,65,67
  </code></pre>
  
  <p>the user can also enter multiple  inputs like <code>2asc,3dec,4dec</code> this means that, the column 2 will be the first to be sorted in ascending order and if they have similar data in that column, the 3rd column will be use displaying them in descending order, then if its still the same use column 4.</p>
  
  <p>for the example above if called using <code>2asc,3dec,4dec</code> it would print as: </p>
  
  <pre><code>Paris,France,78,65,97,87
  Tokyo,Japan,56,78,67,87
  California,USA,65,76,65,67
  New York,USA,65,67,67,44,67
  </code></pre>
  
  <p>My question is, How should I approach this problem?
  What is the best data structure should I use?</p>
  
  <p>PS. Not really asking for code sample, but I am just asking for some hints
  or an approach if you will be given this kind of problem</p>