Thanks.  I ended up using 

reverse sort keys %hash;

-----Original Message-----
From: Hanson, Robert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 2:37 PM
To: Barry Jones; [EMAIL PROTECTED]
Subject: RE: Reverse sort?


To expand on that, the "<=>" operator is for numeric comparisons and
"cmp"
are for string comparisons... make sure you use the right one.

This may also work for what you need...

@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) );

Rob

-----Original Message-----
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 2:30 PM
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]

Reply via email to