Hi Jim,
I'm not entirely clear on what you have in the first array, but it sounds
like it won't be of much use since you already have a hash with all the
information you need.
You're probably going to have to create a new data structure that keys off
of the date so you can search/sort based on the date.
One (poor) way to do it is:
### Make a hash keyed by date:
foreach $vol (keys(old_hash)){
$date = $old_hash{$vol};
$mdy = join('', (split(m{/}, $date))[2,0,1]); ## converts
10/01/2001 --> 20011001, I think :)
$new_hash{$mdy}= $vol; ## %new_hash is indexed by a sortable date key
}
### Sort %new_hash by its keys and print the data to a file
foreach $d (sort(keys(%new_hash))) {
print OUTFILE "$old_hash{$new_hash{$d}} $new_hash{$d}\n";
## prints "10/01/2001 volume_one" to the outfile, I think.
}
Of course, this code really sucks (I didn't even write it, my dog did) but
what do you want for free advice? :)
-- Brad
> I have an array of strings where the first element of the string is a
volume name. The array is sorted by the volume name. I also have hash that
stores dates in the form month/day/year keyed by the volume name.
>
> How would I go about sending to a file the volume names and dates sorted
by the date? I had thought to put the information into another array and
sort it before sending it out. If I do that, how do I sort correctly? Any
suggestions?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]