in reply to sort hash after value from hash in hash

$hash->{'string1'}{$a}

That will not work. You can't lookup a hash key by it's value. You mean

$hash->{$a}{'key1'}

--shmem

update: missed {$a}, corrected

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: sort hash after value from hash in hash
by ocs (Monk) on Nov 24, 2006 at 14:56 UTC
    Yes, thats my mistake, sorry. In the original code it is right (I abstracted this one). I'm going to update this in my example. But nevertheless this solution doesn't work. But the both above mentioned do so :)
      Um, yes. I forgot about the $a,$b gotcha. <nit> Apart from that mistake, your example hash
      $hash = { 1 => { key1 => string1, key2 => string2 } 2 => { key1 => string1, key2 => string2 } }

      is very badly chosen, since the values for each key of the sub-hashes are identical. What do you expect sort to do for you? ,-) </nit>

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        Sorry for this, by adding 1, 2 to the strings I meant only the position of the value :) The strings can not be the same in this case.
        (I really have to learn to create better examples ;))