[EMAIL PROTECTED] wrote:
> Hello guys,

Hello,

> I can't find the solution for sorting a two-dimensional hash.
> I'm sure some of you can help me.

perldoc -q "How do I sort a hash"


> The first dimension of the hash has filenames in it, the second
> consists of two keys, 'data' and 'lines'.
> 
> I want to sort the whole thing by a numerical comparison on 'lines'
> and tried this:
> 
> %toc = sort { print  $toc{$a}{'lines'}."\n"; $toc{$a}{'lines'} <=> 
> %$toc{$b}{'lines'}; } %toc;
> 
> (I also tried a bunch of other things that didn't do the job either,
> but this is the way I think it should work)

my @toc_keys = sort { $toc{ $a }{ lines } <=> $toc{ $b }{ lines } } keys %toc;




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to