in reply to Re: Hash of Arrays - Sort over all array entries
in thread Hash of Arrays - Sort over all array entries

Thanks Abigail-II and tye for the info. This method reduces the number of times through loops from 4 7 in my case, to 2(?) 5.

Of course, whether this is 'easier' is in the eye of the beholder.

Being new to perl I really have to stare at the method above to get the sense of it (I really haven't used map much). So, indeed 'easier' does depend on what you are looking for.

Thanks again.

Update: Changed faulty # of loops :-)

  • Comment on Re: Re: Hash of Arrays - Sort over all array entries

Replies are listed 'Best First'.
Re: Hash of Arrays - Sort over all array entries
by Abigail-II (Bishop) on Sep 09, 2003 at 22:36 UTC
    <bq> This method reduces the number of times through loops from 4 in my case, to 2(?). </bq>

    Actually, I count 5 loops: keys, map, map, sort, for.

    Abigail

Re^3: Hash of Arrays - Sort over all array entries (nesting)
by tye (Sage) on Sep 10, 2003 at 16:06 UTC
    This method reduces the number of times through loops

    The number of loops is usually less important than how they are nested. 5 loops, none of them nested means run-time on the order of O(5*$n) which is O($n). You had three of your loops nested which is more like O($n**3).

    In this case, the loop sizes are more like $n (number of families), $m (number of members per family), and $n*$m (total number of members) so we go from O( ($n*$m)**2 ) to just O($n*$m).

                    - tye