3
Suppose I have this file
b 10 foo
a 10 bar
a 2 bar
I want to sort by the third colum, alphabetically. In case of ties, I want to sort by the second column, numerically. In the man page for the unix sort program you find this:
> sort -k3 -k2n a
Which gives
a 2 bar
a 10 bar
b 10 foo
Which is correct.
Now, what I actually want, is to sort by the first column, alphabetically, and in case of ties, by the second column, numerically. Can anybody explain to me why
> sort -k1 -k2n a
Gives
a 10 bar
a 2 bar
b 10 foo
Which is plain wrong?
1try -k1,1 -k2,2n but this is really more a superuser question since no programming is involed – frankc – 2012-11-09T17:19:15.793