Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: text sorting question

by eak (Monk)
on Aug 03, 2000 at 00:58 UTC ( #25849=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://25849]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2022-01-21 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?