Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Question: best way to sort an hash of hashes

Expand Messages
  • Jeff 'japhy' Pinyan
    ... You re very welcome. ... Heheh. I d suggest looking at http://learn.perl.org/ too. ... Offhand, I can t really think of many beginner-level resources out
    Message 1 of 9 , Jul 26 10:21 AM
      On Jul 26, Bob Alexander said:

      > Jeff 'japhy' Pinyan wrote:
      > > Finally, although this might be a bit much for you, you can chain those
      >> two statements together to create your desired data structure in one go.
      >> This type of mechanism should be read bottom-to-top; that is, first
      >> values(%log), then the map(), and then the sort().
      >> my @flat =
      >> sort {
      >> ($a->[0] <=> $b->[0]) or
      >> ($a->[2] cmp $b->[2]) or
      >> ($a->[1] <=> $b->[1])
      >> } map [@$_{'logintime', 'logouttime', 'username'}],
      >> values %log;
      > WOW !
      > Thanks a lot Japhy.

      You're very welcome.

      > I will spend some of my free time studying your code and after reading
      > it along with the perldoc help I might even learn something :) !!!

      Heheh. I'd suggest looking at http://learn.perl.org/ too.

      > BTW suppose I want to understand how the sort function really works. If
      > I give perldoc sort but this is not what I want. perldoc perlfunc is
      > what I need but to a beginner like me the descriptio although extremely
      > precise is a bit obscure. What are more beginner friendly sources other
      > than printed books which I could download and keep on my portable since

      Offhand, I can't really think of many beginner-level resources out there,
      but that's because I haven't used them in such a long time. ;) I'd guess
      learn.perl.org has some good links.

      Jeff "japhy" Pinyan % How can we ever be the sold short or
      RPI Acacia Brother #734 % the cheated, we who for every service
      http://japhy.perlmonk.org/ % have long ago been overpaid?
      http://www.perlmonks.org/ % -- Meister Eckhart
    Your message has been successfully submitted and would be delivered to recipients shortly.