More readable/maintainable is: @items = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); @sortedItems = reverse sort @items; #reverse sort the array print "@sortedItems";
Which gives the following as the answer: foreach reverse sort keys %myhash { print "$_ : $myhash{$_}\n"; } /\/\ark -----Original Message----- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 21, 2002 11:30 AM To: 'Barry Jones'; [EMAIL PROTECTED] Subject: RE: Reverse sort? You can do it like this: @items = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); @sortedItems = sort{$b <=> $a}@items; #reverse the sort print "@sortedItems"; When you use the <=> operator, you can specify the direction by where you put the $a and $b variables. -----Original Message----- From: Barry Jones [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 21, 2002 11:23 AM To: [EMAIL PROTECTED] Subject: Reverse sort? How can I sort a hash's keys in reverse order? Barry Jones DATABUILT, Inc. The Global AEC Information Company 1476 Fording Island Rd. Bluffton, SC 29910 (843) 836-2166 office "Life is like a dogsled team; if you ain't the lead dog, the scenery never changes." - Lewis Grizzard -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]