title: Linux Column Sort Function
body: <p>I am trying to sort a file with 4 columns by the column that is input. My code below will only sort based on the first column no matter what the input of $field is.</p>
  
  <pre><code>if (( sort ))
  then
          if [ $field==1 ]
          then
                  sort -k1 $file -o $file
          elif [ $field==3 ]
          then
                  sort -k3 $file -o $file
          elif [ $field==4 ]
          then
                  sort -k4 $file -o $file
          else #for field 2-- this is default
                  sort -k2 $file -o $file
          fi
  fi
  </code></pre>