oops that should have been @sorted_keys = sort { $hash{$a}[1] cmp $hash{$b}[1] } keys %hash; -----Original Message----- From: Nikola Janceski [mailto:nikola_janceski@summithq.com] Sent: Wednesday, February 06, 2002 11:48 AM To: 'birgit kellner'; beginners@perl.org Subject: RE: sort on anonymous array elements as hash values yes: @sorted_keys = sort { $hash{$a}[2] cmp $hash{$b}[2] } keys %hash; -----Original Message----- From: birgit kellner [mailto:birgit.kellner@aon.at] Sent: Wednesday, February 06, 2002 11:36 AM To: beginners@perl.org Subject: sort on anonymous array elements as hash values my %hash = ( 'keyone' => ['firstvalueone', 'firstvaluetwo], 'secondkey' => ['anothervalueone', 'valuetwoforsecondkey'], 'keythree' => ['thirdvalueone', 'thirdvaluetwo'] ); Can I sort the hash on the second element of the anonymous array? Output should be: firstvaluetwo thirdvaluetwo valuetwoforsecondkey Many thanks in advance, Birgit Kellner -- To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc.Thread Previous | Thread Next