LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   ordering row entries (https://www.linuxquestions.org/questions/programming-9/ordering-row-entries-309870/)

rohr 04-05-2005 05:30 AM

ordering row entries
 
Hi everyone,
i have ASCII data file arranged like this:
91.4003 68.3866
87.6442 69.8278
84.0744 71.0456
46.9484 76.6493
40.4647 75.4198
38.8101 73.5891
31.8823 75.5027
26.1525 72.0757
22.14 71.1328
88.0006 69.9159
50.7118 76.5928
34.7055 76.6495
31.6318 75.5847
29.3048 74.9038
87.135 69.8612
72.9801 71.0002
72.7959 70.7315
66.3057 69.7786
48.0911 77.2035
..... .....
..... .....
..... .....

and i have to plot them. But if i attempt to do this via gnuplot, linking all points with straight lines, i got a full mess because data on x-axis taken from the first column are not in upgrading order.

So i need to get another ASCII file where the entries of first column are arranged from the lowest to highest, keeping the matching with the corresponding y-axis values taken from the second column, of course.

Is there a way to accomplish this via awk or anything similar?
Thank you in advance!

jkobrien 04-05-2005 05:45 AM

sort -nk1,1

rohr 04-05-2005 06:31 AM

thanks

twantrd 04-08-2005 03:24 PM

Wow, thanks too. I'm guessing 1,1 is the column reference?

-twantrd

jkobrien 04-11-2005 04:36 AM

Yes,

See 'man sort' or 'info sort' for more. The first 1 means begin the sort key at column one, the second 1 means end it there too.

The 'n' means to use numeric order.

John


All times are GMT -5. The time now is 01:09 AM.