On Thu, 31 May 2001, David Michael wrote:
> Hello,
> I have a hash that needs to be displayed in a certain order. I tried
>
> foreach $key (sort (keys %HASH)) {
> print $key;
> }
>
> that sorts alphabetically. I need it in the order it was inserted,
> so I made the value a number that increased for each key. I need to
> sort by the value, but display the key. Any ideas ?
The most streamlined way is to use the Tie::IxHash module. When you tie a
hash to this class, you can retrieve the keys in the order they were
inserted. Recipe 5.6 in the Perl Cookbook has more details on this.
-- Brett
Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]