On Sat, Jul 22, 2000 at 04:18:07PM -0400, Bernie Cosell wrote: > On 22 Jul 2000, at 10:10, Bernie Cosell wrote: > > hopping on my own not-so-fun thread, > > > my @arrayofstuff ; > > push @arryofstuff, [ [ key1, key2, key3, key4, ....] , value ] > > > > Then I want to sort that if there were a fixed number of 'key' values > > could do as: > > $a->[0][0] cmp $b->[0][0] or $a->[0][1] cmp $b->[0][1] or ... > > [and then after the sort, a final: > > map { $_->[1] } [SORTEDLIST]. > > Well, here's something I played with this afternoon that actually works > pretty well --- GIVEN: that the 'key's are actually text strings [in > particular, do NOT have embedded NULL characters], when you make > @arrayofstuff, instead of the above you make it: > push @arrayofstuff, [ join("\0", key1, key2, ....), value ] > > then you can just do: > map $_->1, sort { $a->[0] cmp $b->[0] } @arrayofstuff > > maybe that's kind of fun [program bumming that an embedded NULL character > actually works the same as code to "move to the next section of the key"] Or you do it GRTish: map {(split /\0/) [-1]} sort map {join "\0" => key1, ... , keyn, value} Abigail ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe