title: Linux sort numerically based on first column
body: <p>I'm trying to numerically sort a long list of csv file based on the number in the first column, using below command:</p>
  
  <pre><code>-&gt;  head -1 file.csv ; tail -n +2 file.csv | sort -t , -k1n
  </code></pre>
  
  <p>(I'm piping head/tail command to skip the first line of the file, as it's a header and contains string)
  However, it doesn't return a fully sorted list. Half of it is sorted, the other half is like this:</p>
  
  <pre><code>9838,2361,8,947,2284
  9842,2135,2,261,2511
  9846,2710,1,176,2171
  986,2689,32,123,2177
  9888,2183,15,30,2790
  989,2470,33,887,2345
  </code></pre>
  
  <p>Can somebody tell me what I'm doing wrong? I've also tried below with same result:</p>
  
  <pre><code>-&gt; sort -k1n -t"," file.csv
  </code></pre>