in reply to Hashes - sorting keys

my @temps = sort { $a <=> $b } keys %hash; my @fluors = @hash{@temps};
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Hashes - sorting keys
by Skeeve (Parson) on Jul 15, 2003 at 10:21 UTC
    You should explain it to him.

      What needs explaining?

      # get a sorted list of hash keys and store in array @temps my @temps = sort { $a <=> $b } keys %hash; # use a hash slice to get list of values in the same order # as the keys in @temps and store in array @fluors my @fluors = @hash{@temps};
      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        Didn't you see that he seems to be hopelessly lost doing useless things?