On Jan 31, [EMAIL PROTECTED] said: >I have a simple hash with directory names as keys and sizes as values. I >would like to print the hash, in descending order of the size of each >directory.
# this sorts your keys based on their values, descending @keys = sort { $hash{$b} <=> $hash{$a} } keys %hash; >I was contemplating of "reversing" the hash(so that sizes become keys and >directory names become values) and then do a sort on the keys. However, this >approach would not work if two directories have the same sizes, as that >would "flatten" the keys list! Reversing the hash is more work than it's worth, as you've found out. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]