Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 05:00:44PM -0400, Jeff 'japhy' Pinyan wrote: > On Aug 9, Jeremy Kister said: > > >>my @s = map $_->[ 1 ], > >>sort { $a->[ 0 ] cmp $b->[ 0 ] } > >>map [ inet_aton( $_->{ N } ), $_ ], > >>@a; > > > >Now to analyze WTF we're doing here :) > > Paul'

Re: more hashref within array sorting

2005-08-09 Thread Jeff 'japhy' Pinyan
On Aug 9, Jeremy Kister said: my @s = map $_->[ 1 ], sort { $a->[ 0 ] cmp $b->[ 0 ] } map [ inet_aton( $_->{ N } ), $_ ], @a; Now to analyze WTF we're doing here :) Paul's answer had a slight typo in it -- he was comparing $a->[0], $a->[1], $a->[2], and $a->[3], wh

Re: more hashref within array sorting

2005-08-09 Thread Jeremy Kister
On 8/9/2005 8:43 AM, John W. Krahn wrote: > Jeremy Kister wrote: >>I've apparently dumbed down my code and question a bit too much: I have >>multiple hashrefs in each element of the array, and I need the resulting >>sorted array to contain all the data in the original array, simply >>sorted by the

Re: more hashref within array sorting

2005-08-09 Thread John W. Krahn
Jeremy Kister wrote: > On 8/9/2005 6:26 AM, Paul Johnson wrote: >>my @s = map { $_ -> [0] } >>sort { $a->[0] <=> $b->[0] || >> $a->[1] <=> $b->[1] || >> $a->[2] <=> $b->[2] || >> $a->[3] <=> $b->[3] } >>map { [ $_, split /\./ ] } >>

Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 06:53:33AM -0400, Jeremy Kister wrote: > On 8/9/2005 6:26 AM, Paul Johnson wrote: > > my @s = map { $_ -> [0] } > > sort { $a->[0] <=> $b->[0] || > >$a->[1] <=> $b->[1] || > >$a->[2] <=> $b->[2] || > >$a->[3] <=> $b->

Re: more hashref within array sorting

2005-08-09 Thread Jeremy Kister
On 8/9/2005 6:26 AM, Paul Johnson wrote: > my @s = map { $_ -> [0] } > sort { $a->[0] <=> $b->[0] || >$a->[1] <=> $b->[1] || >$a->[2] <=> $b->[2] || >$a->[3] <=> $b->[3] } > map { [ $_, split /\./ ] } > map { $_->{N} } @a;

Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 06:03:18AM -0400, Jeremy Kister wrote: > I've got an array full of hashrefs: > my @a = ( {N => '10.1.2.1'}, > {N => '10.1.9.1'}, > {N => '10.3.5.1'}, > {N => '10.1.1.3'}, > ); > > I want to sort this array, and print. I expect the ou