title: reordering columns with AWK
body: <p>I need to reorder the columns of this (tab-separated) data:</p>
  
  <pre><code>   1 cat    plays
     1 dog    eats
     1 horse  runs
     1 red    dog
     1 the    cat
     1 the    cat
  </code></pre>
  
  <p>so that is prints like:</p>
  
  <pre><code>cat plays   1
  dog eats    1
  horse   runs    1
  red dog 1
  the cat 2
  </code></pre>
  
  <p>i have tried:</p>
  
  <pre><code>sort [input] | uniq -c | awk '{print $2 "\t" $3 "\t" $1}' &gt; [output]
  </code></pre>
  
  <p>and the result is:</p>
  
  <pre><code>1   cat 1
  1   dog 1
  1   horse   1
  1   red 1
  2   the 1
  </code></pre>
  
  <p>Can anyone give me some insight on what is going wrong?
  Thank you.</p>