help printing out items in order
I create an associate array with fields..
filename1
desc2
date3
author4
filename5
desc6
date7
author8
..
and so on
but when I print them out using a foreach loop they printout in a different order than what they were entered into the array as. I don't want to printout the items by the data that the field is associated with, just by the way the fields are in the associative array just like what I listed above.
Does the order of the fields get changed within the array?
Thanks,
atdawg
Ray Goniea posted this at 16:07 — 11th December 1999.
They have: 11 posts
Joined: Nov 1999
Atdawg,
An associative array returns your list in a random order.
You can use "sort" to list them alphabetically. Here is a small snippet of code
foreach $key (sort keys %category)
Ray
Rob Pengelly posted this at 16:21 — 11th December 1999.
They have: 850 posts
Joined: Jul 1999
Check out
http://search.cpan.org/doc/GSAR/Tie-IxHash-1.21/lib/Tie/IxHash.pm
It is a module you can download, and it preserve the order in which the hash elements were added
------------------
A 'jiffy' is an actual unit of time for 1/100th of a second.
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
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.