awk sorting

Hi, I have used the following code to sort two sets of data:

 awk '{printf "%10s %s\n",$1,$2}'

The first column is text and the second involves numbers. I was just wondering how i would go about sorting the second number so that they ascend from the top?

Thanks for any help

interesting.....
Could you explain how the above actually accomplished the 'sorting'?

Sorry, I miss typed, was quite late at nigh -_-. I meant to ask how would I go about sorting the second column of data (which are numbers) in ascending order.

I currently haven't sorted any data. I can sort the first set of data quite simply by adding a " | sort" at the end of the pipe, but by default this sorts the first column, but i want to sort the second.

Sorry about that :stuck_out_tongue:

.... | sort -k 2n

Hmmm, when I sorted I got this:

sort: option requires an argument -- k
Try `sort --help' for more information.
user:~/test> man sort
Reformatting sort(1), please wait...

So I changed it to this:

sort -nr +1 -2

Which worked.

Thanks for your help btw :cool: