Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to sort the GPA in a file for my class lab. The teacher uses putty, for those of us that chose to use Ubuntu in the class, we have no idea how to do the command for ascending sort and descending sort.

share|improve this question
Is it a text file – Manula Waidyanatha Jul 14 '12 at 2:24
Nam     GPA    Something
xyz     3.4     99  
pqr     4.5     23  
abc     5.6     44  
dcd     4.4     22  
edr     2.2     78

If you have a file like above. You can use the command below to sort by GPA. (change the key to sort by any field : '-k value')

sort -k 2 filename

If you want the reverse order use -r option

sort -r -k 2 filename
share|improve this answer

PuTTy is just the program used to connect to a computer.

There's a lovely command called sort you may wish to try.

Another man for manual, will give you all sorts of good information.

Try man sort or even the manual for the manual man man.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.