Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting problems

Status
Not open for further replies.

jett

Technical User
Sep 13, 2000
22
0
0
US
I have a sorting question. Picture a datafile with about ten fields seperated by ‘:’.
The first field is unique and nummeric. As records are printed on the bottom of the datafile after a modification I would like to do a sort on the first field of the datafile to move the modified record to the right spot.

With the help of some manuals I tried something like this:

#sort prop
open (data, &quot;<$profile&quot;) or &error(&quot;Unable to open the data file&quot;);
@data=<data>;
close(data);
@datax=split(/:/, $data);
@data = sort {$a <=> $b} @datax;
open (wdata, &quot;>$profile&quot;) or &error(&quot;Unable to write to the data file&quot;);
print wdata @data;
close(wdata);

Obviously this is not correct as the whole database is deleted after this!

Hopefully there is somebody who can tell me what I'm doing wrong?

Jett [sig][/sig]
 
Think it is solved.

#sort prop
open (data, &quot;<$profile&quot;) or &error(&quot;Unable to open the data file&quot;);
@data=<data>;
close(data);
@data = sort {$a <=> $b} @data;
open (wdata, &quot;>$profile&quot;) or &error(&quot;Unable to write to the data file&quot;);
print wdata @data;
close(wdata);

Jett, [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top