Re: Maximum value in Hash

2006-10-02 Thread Andrej Kastrin
John W. Krahn wrote: Andrej Kastrin wrote: Dear all, Hello, I'm looking for simple (and fast) solution to extract maximum value from a hash. I search over the Perl mailing lists, but I didn't find anything usable. One way to do it: my $max; $max < $_ and $max = $_ for valu

Re: Maximum value in Hash

2006-10-02 Thread John W. Krahn
Andrej Kastrin wrote: > Dear all, Hello, > I'm looking for simple (and fast) solution to extract maximum value from > a hash. I search over the Perl mailing lists, but I didn't find anything > usable. One way to do it: my $max; $max < $_ and $max = $_ for values %hash; And another way: my $m

RE: Maximum value in Hash

2006-10-02 Thread Wijaya Edward
It depends what do you mean by maximum. Assume you have numerical value as hash values. You can do: use List::Util qw(max) my %hash = { foo => 3, bar=>2, qux=> 1}; my $max_val = max values %hash; Hope that helps. -- Regards, Edward WIJAYA From: Andrej Kast

RE: Maximum value in Hash

2006-10-02 Thread Lee Goddard
sort values %hash? -- Lee Goddard Independent Contractor, Software Development/Analysis BBC Radio & Music Interactive * Room 718 | Henry Wood Hs | Regents St | London W1 1AA | UK * 020 776 50849 * lee(at)server-sidesystems.ltd.uk > -Original Message- > From: Andrej Kastrin [mailto:[