sort by keeping the headings intact?

Hi all,

I have a file with 3 columns separated by space. Each column has a heading. I want to sort according to the values in the 2nd column (ascending order).

Ex.

Name rank direction
goory 0.05 --+
laby 0.0006 ---
namy 0.31 -+-

....etc.

Output should be

Name rank direction
laby 0.0006 ---
goory 0.05 --+
namy 0.31 -+-

Can somebody help me with this?
Thanks!:confused:

sort -nk2 file

Thanks bartus!! What is the difference between sort -nk2,2 and your code?

From the man pages:
-k, --key=POS1[,POS2] start a key at POS1, end it at POS2 (origin 1)

Pos2 is when you want give it a range. You can skip pos2 if your key is only col2 like in this case.

But to answer your question, sort -nk2 is equivalent to sort -nk 2,2