On Thu, May 17, 2001 at 05:25:52PM +0100, Simon Cozens wrote:
> On Thu, May 17, 2001 at 05:15:56PM +0100, David Cantrell wrote:
> > Did you mean like this?
> >
> > tie my %scores, 'Tie::Hash::Rank';
> > [overengineering snipped]
> 
> Or you could do it in two lines:
> 
> my $i;
> my %rank = map { $_ => ++$i } sort {$scores{$a} <=> $scores{$b}} keys %scores;

Ah, but those don't do the same do they.  You have to regenerate your
rankings whenever you add a new score, whereas mine lets you get the rankings
directly from the hash.  Of course, it makes it impossible to retrieve the
scores themselves.

EINSUFFICIENTLYSPECIFIEDPROBLEM :-)

-- 
David Cantrell | [EMAIL PROTECTED] | http://www.cantrell.org.uk/david/

  Rip, Mix, Burn, unless you're using our "most advanced operating system
   in the world" which we decided to release incomplete just for a laugh

Reply via email to