develooper Front page | perl.beginners | Postings from February 2002

Sorting a hash table - Advanced;)

Thread Next
From:
Steven M. Klass
Date:
February 27, 2002 08:39
Subject:
Sorting a hash table - Advanced;)
Message ID:
200202271637.g1RGbXc12538@vivids1.nsc.com
Hi all,

ok here is the fundamental code

print "\n\n**Summary**\n";
foreach my $key (keys %runset){ 
    printf ( "%-20s %-20s\n",$key, $runset{$key});
}

Now I want to sort this hash for example
print "\n\n**Summary**\n";
foreach my $key (keys %runset){ 
    print "Name		$runset{foo}"
    # .. other specific keys
    printf ( "%-20s %-20s\n",$key, $runset{$key});
}

The question is how can I sort the remaining keys that I haven't already 
printed before.

Basically I want to format this so certain keys get printed in a certain 
order, but there may be some remaining keys that I want printed that I really 
don't care about.  (a "catch-all" if you will)

Thanks

-- 

 Steven M. Klass
 Physical Design Manager

 National Semiconductor Corp
 7400 W. Detroit Street
 Suite 170
 Chandler AZ 85226

 Ph:480-753-2503
 Fax:480-705-6407

 steven.klass@nsc.com
 http://www.nsc.com


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About