trying to make an AWK code for ordering numbers in a column from least to highest

Hi all,

I have a large column of numbers like

5.6789
2.4578
9.4678
13.5673
1.6589
.....

I am trying to make an awk code so that awk can easily go through the column and arrange the numbers from least to highest like

1.6589
2.4578
5.6789

.......
can anybody suggest, how can I do this:confused:

you can get ur output in sort command itself.

sorn -n <filename>

please find the example:

$more a1
5.6789
2.4578
9.4678
13.5673
1.6589
2.8888
2.7593
124.234
3.3333
5.8990
99.234234
100.23432
2343
15799.00
$sort -n a1
1.6589
2.4578
2.7593
2.8888
3.3333
5.6789
5.8990
9.4678
13.5673
99.234234
100.23432
124.234
2343
15799.00
$

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

hi thanks a lot for that....actually what i want to do is......i have a file with four columns like

1 2 4 5.6789
3 1 5 2.4578
1 3 2 9.4678
2 4 1 13.5673

So I want to order all the lines but on the basis of ordering the fourth column from least to highest value. something like this:-

3 1 5 2.4578
1 2 4 5.6789
1 3 2 9.4678
2 4 1 13.5673

thanks for your comments

Simply

sort -k4rn file

thanks ripat
sort -k4n file worked for me....i just removed the "r"