LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-05-2005, 04:30 AM   #1
rohr
Member
 
Registered: Jan 2005
Distribution: debian
Posts: 44

Rep: Reputation: 15
Talking 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!
 
Old 04-05-2005, 04:45 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
sort -nk1,1
 
Old 04-05-2005, 05:31 AM   #3
rohr
Member
 
Registered: Jan 2005
Distribution: debian
Posts: 44

Original Poster
Rep: Reputation: 15
thanks
 
Old 04-08-2005, 02:24 PM   #4
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,438

Rep: Reputation: 52
Wow, thanks too. I'm guessing 1,1 is the column reference?

-twantrd
 
Old 04-11-2005, 03:36 AM   #5
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ordering a Dell Laptop carlosinfl Linux - Laptop and Netbook 6 12-04-2005 02:07 AM
Ordering Linux CDs LinuxNewUser Linux - Newbie 13 04-25-2005 12:54 AM
Partition Ordering Problems Tide Linux - Newbie 11 05-24-2004 03:21 PM
What should you know before ordering another harddrive for Linux? Mackan Linux - Hardware 6 11-25-2003 11:18 PM
ordering the mandrake package highhighs Mandriva 3 09-03-2003 01:57 PM


All times are GMT -5. The time now is 12:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration