title: Sorting csv according to particular column
body: <p>Hi I am exporting data to csv file using javascript. I need to sort the data according to specific column index.</p>
  
  <p>Code:</p>
  
  <pre><code>      $.each(exportArray, function (index, value) {
  csvData.push(x[index] + "," + y[index] + "," + d[index] + "," + z[index]  + ","+ a[index] + "," + e[index] + "," + b[index] + "," + c[index]);
          });
  csvData.sort();
  
           csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(output);
  
        $(this)
  .attr({
      'download': filename,
      'href': csvData,
      'target': '_blank'
  });
  </code></pre>
  
  <p>E.g.: <code>csvData.sort()</code> is sorting data acoording to first column as default. I want to have it sorted according to the third column i.e.. by <code>d[index]</code>.
  I tried this <code>csvData.sort(sort_by(d[index]));</code> and it is not working.</p>
  
  <p>I have one more issue . Since I am exporting the data to csv. Now in <code>d[index]</code> from the server if I have three values like <code>d[index]="cat,dog,bat"</code> . It is getting displayed in 3 adjacent columns. I want it in the same column. Can I change the delimiter to something else from comma.</p>
  
  <p>Code:</p>
  
  <pre><code>       csvData.push(x[index] + "," + y[index] + "," + d[index] + "," + z[index]  + ","+ a[index] + "," + e[index] + "," + b[index] + "," + c[index]);
  </code></pre>