CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Frequently Asked Questions:
How Do I Sort A Hash by Either Value Or Key



Dec 12, 2000, 2:43 PM

Post #1 of 1 (8563 views)
How Do I Sort A Hash by Either Value Or Key Can't Post

Here is a good example of how to sort a hashes records by value, please pay attention to the 3rd and 4th posts by myself and rGeoffrey, the first two of mine are BAD coding examples, DO NOT USE THEM.

To sort a hash by key, is much more simple,

foreach $key (sort keys %hash){
print "sorted key: $key, value: $hash{$key}";

An excellent article about hashes written by Jasmine the administrator of this site can be found here.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives