in reply to Re: sort hash after value from hash in hash
in thread sort hash after value from hash in hash

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 :)
  • Comment on Re^2: sort hash after value from hash in hash

Replies are listed 'Best First'.
Re^3: sort hash after value from hash in hash
by shmem (Chancellor) on Nov 24, 2006 at 15:00 UTC
    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 ;))
        Simply take a real world example, with code that actually runs - not like your pseudocode that produces errors (unquoted strings, missing comma). Then write what you expected as output and what you got instead.

        This way, the monks here can quickly copy and paste your code, try it out and fix it for you :).

        -- Hofmator

        Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.