Re: Sorting a hash

2004-10-04 Thread Gunnar Hjalmarsson
Octavian Rasnita wrote: Gunnar Hjalmarsson wrote: You don't need another hash. perldoc -f sort perldoc -q "sort a hash" my @codes = sort { $comp{$a}{$year}{profit} <=> $comp{$b}{$year}{profit} } keys %comp; I have tried that, but it gave me an error

Re: Sorting a hash

2004-10-04 Thread Octavian Rasnita
From: "Gunnar Hjalmarsson" <[EMAIL PROTECTED]> > >> You don't need another hash. > >> > >> perldoc -f sort > >> perldoc -q "sort a hash" > >> > >> my @codes = sort { > >> $comp{$a}{$year}{profit} > >> <=> > >> $comp{$b}{$year}{profit} > >> } keys %

Re: Sorting a hash

2004-09-28 Thread Paul Archer
11:57am, Octavian Rasnita wrote: > Hi all, > > I have a hash that have multiple sub hashes and I want to sort it by a sub > key. > > For example, I have: > > $comp{$code}{$year}{profit}. > > And I want to sort the $code values after the value of the "profit" key. > > Is this possible directly, or

Re: Sorting a hash

2004-09-28 Thread Gunnar Hjalmarsson
Aben Siatris wrote: DÅa Tuesday 28 September 2004 11:42 Gunnar Hjalmarsson napÃsal: Octavian Rasnita wrote: I have a hash that have multiple sub hashes and I want to sort it by a sub key. For example, I have: $comp{$code}{$year}{profit}. And I want to sort the $code values after the value of the "p

Re: Sorting a hash

2004-09-28 Thread Aben Siatris
DÅa Tuesday 28 September 2004 11:42 Gunnar Hjalmarsson napÃsal: > Octavian Rasnita wrote: > > I have a hash that have multiple sub hashes and I want to sort it > > by a sub key. > > > > For example, I have: > > > > $comp{$code}{$year}{profit}. > > > > And I want to sort the $code values after th

Re: Sorting a hash

2004-09-28 Thread Gunnar Hjalmarsson
Octavian Rasnita wrote: I have a hash that have multiple sub hashes and I want to sort it by a sub key. For example, I have: $comp{$code}{$year}{profit}. And I want to sort the $code values after the value of the "profit" key. Is this possible directly, or I will need to create another hash for doi

Sorting a hash

2004-09-28 Thread Octavian Rasnita
Hi all, I have a hash that have multiple sub hashes and I want to sort it by a sub key. For example, I have: $comp{$code}{$year}{profit}. And I want to sort the $code values after the value of the "profit" key. Is this possible directly, or I will need to create another hash for doing this typ

Re: Sorting a hash by values?

2002-06-08 Thread Janek Schleicher
Octavian Rasnita wrote at Fri, 07 Jun 2002 21:54:02 +0200: > I want to make a script that sorts the values from a hash. my @sorted_values = sort {$a <=> $b} values %hash; > > I want to make a "top with the most downloaded files". > > I know how to sort the hash by keys but I couldn't sort it

Sorting a hash by values?

2002-06-07 Thread Octavian Rasnita
Hi all, I want to make a script that sorts the values from a hash. I want to make a "top with the most downloaded files". I know how to sort the hash by keys but I couldn't sort it by values. I have a hash like: %hash = ( file1 => 3, file2 => 11, file3 => 6, fileN => 22 ); I would like