in reply to text sorting question, kinda

if you can get the data into an array of arrays, the following would work very nicely. There is probably a nicer way to do the loop, than a foreach though.
#!/usr/bin/perl -w my @array = ( ['foo', 1, 'zot'], ['foo', 2, 'blahblah'], ['bar', 1, 'zot'], ['bar', 2, 'zot'], ['bat', 1, 'blahblah'], ['bat', 2, ''], ['baz', 1, ''], ['baz', 2, 'zot'], ); my @sorted; foreach my $array (@array){ ($array->[2] eq 'blahblah' ? unshift @sorted, $array : push @sorted, + $array); }
--eric

Replies are listed 'Best First'.
(Ovid) RE(2): text sorting question
by Ovid (Cardinal) on Aug 03, 2000 at 01:01 UTC
    That's a nice example, but it reverses the order of the "blahblah" lines. That was something that ybiC was trying to avoid. I spotted that immediately because I made the same mistake at first :)

    Cheers,
    Ovid