JupiterHost.Net wrote:
Hello,
Long week and brain is off :)
I have a hash like so:
my %data = ( 'foo' => { sorton => 2, data => 'blah' }, 'bar' => { sorton => 1, data => 'yike' }, 'baz' => { sorton => 3, data => 'zipp' }, );
for(sort %data) { print ${ $data{$_} }{data},"\n"; }
Ok, I think I may have it:
for(sort { $data{$a}->{sorton} <=> $data{$b}->{sorton} } keys %data) { print $data{$_}->{data} . "\n"; }
Does that look right? (IE is it doing what I think it is or does it just look that way?)
Its late and this week has been nuts :) Just need a sanity check...
Thanks :)
output: yike zipp blah
I'd like to sort them on the sorton key so it is:
yike blah zipp
so like I said my brain has stopped completely, so how can I so the for( sort ??? ) {
to sort on the sorton key of the hash ref?
TIA :)
Lee.M - JupiterHost.Net
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>