in reply to sorting a file - multilevel

I would just use sort (not sort). Except that it looks like the "10th" position in your file is just the string "UTR". How are you counting columns?

Replies are listed 'Best First'.
Re^2: sorting a file - multilevel
by ini2005 (Novice) on Jun 14, 2008 at 10:08 UTC

    Yes, the 10th col is UTR but it varies, ti can be GENE, CDS, RNA..

    another problem is that I need GENE to always be first (not regular lexicographic sort)

      another problem is that I need GENE to always be first (not regular lexicographic sort)
      That's doable...here's a sample (the sed and awk can easily be replaced by perl...left as an exercise):
      #!/bin/ksh awk 'BEGIN { SORTCD["GENE"] = 1 SORTCD["CDS"] = 2 SORTCD["RNA"] = 3 } { print SORTCD[$3], $0 }' <<EOT | 1 1 RNA 1 1 GENE 1 2 CDS EOT sort -n -k2,3 -k1,1 | sed -e 's/^[0-9]* //'