title: Bash CSV sorting and unique-ing
body: <p>a Linux question: I have the CSV file <code>data.csv</code> with the following fields and values</p>
  
  <pre><code>KEY,LEVEL,DATA
  2.456,2,aaa
  2.456,1,zzz
  0.867,2,bbb
  9.775,4,ddd
  0.867,1,ccc
  2.456,0,ttt 
  ...
  </code></pre>
  
  <p>The field <code>KEY</code> is a float value, while <code>LEVEL</code> is an integer. I know that the first field can have repeated values, as well as the second one, but if you take them together you have a unique couple.</p>
  
  <p>What I would like to do is to sort the file according to the column <code>KEY</code> and then for each unique value under <code>KEY</code> keep only the row having the higher value under <code>LEVEL</code>.
  Sorting is not a problem:</p>
  
  <pre><code>$&gt; sort -t, -k1,2 data.csv  # fields: KEY,LEVEL,DATA
  0.867,1,ccc
  0.867,2,bbb
  2.456,0,ttt
  2.456,1,zzz
  2.456,2,aaa
  9.775,4,ddd
  ...
  </code></pre>
  
  <p>but then how can I filter the rows so that I get what I want, which is:</p>
  
  <pre><code>0.867,2,bbb
  2.456,2,aaa
  9.775,4,ddd
  ...
  </code></pre>
  
  <p>Is there a way to do it using command line tools like <code>sort</code>, <code>uniq</code>, <code>awk</code> and so on? Thanks in advance</p>