Sorting Question...
Ok, I am using a form to write to a data file... the script writes in the following format:
name|url|description|etc|etc|etc
Then, the script will print out the file in nicely organized tables... the thing is, I would like to sort the data alphabetically by name before I print it (or before I write to the file?) How would I go about doing this?
------------------
Steve Caponetto http://whz.net
[This message has been edited by whz (edited 20 March 2000).]
Steve Caponetto
http://whz.net
Rob Pengelly posted this at 22:43 — 20th March 2000.
They have: 850 posts
Joined: Jul 1999
Are you just appending the new entry to the file?
You could do somthing like this
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
whz posted this at 04:16 — 21st March 2000.
They have: 7 posts
Joined: Mar 2000
Ok, I realize I didn't explain what I wanted very well in my first post..
Ok, The text file has a bunch of data in the form of
name|url|comments|etc|etc...
Then, I am going to be printing out each line of data in nicely formatted tables. What I want to do is when I print out each line of data, I would like them to be printed on the screen in alphabetical order based upon the first data entry - the name. How would I go about sorting these data entries in alphabetical order based upon the first "name" field?
------------------
Steve Caponetto
http://whz.net
Steve Caponetto
http://whz.net
Stefen Enns posted this at 05:06 — 21st March 2000.
He has: 150 posts
Joined: Apr 1999
The following code should do the job fine.
open (file,"file.dat");
@data = <file>;
close(FILE);
@data = sort @data;
whz posted this at 05:28 — 21st March 2000.
They have: 7 posts
Joined: Mar 2000
Thanks Stefan. That worked
------------------
Steve Caponetto
http://whz.net
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.