Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: How can I sort this data on the first field

by jhourcle (Prior)
on Apr 25, 2005 at 13:28 UTC ( [id://451181]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I sort this data on the first field
in thread How can I sort this data on the first field

The example can, but as soon as you have numbers that are a different order of magnitude, it will fail:

print sort <DATA>; __DATA__ 9|microsoft 70|aol 108|netscape 35|mozilla 40|opera

Based on the similarity of this example, with that in Need help with searching flatfile and updating it., I can only assume that the numbers aren't going to remain static.

Replies are listed 'Best First'.
Re^4: How can I sort this data on the first field
by Chady (Priest) on Apr 25, 2005 at 17:29 UTC

    I left this out on purpose :)

    You still can do it without manipulating the original data.

    print sort { $a <=> $b } <DATA>; __DATA__ 9|microsoft 70|aol 108|netscape 35|mozilla 40|opera

    The main issue here is what you want to do with the data at the end, since you're printing it in the same format as it started with, then you don't need to split it only to join it back at the end since sort will work either way.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
    Chady | http://chady.net/
    Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-19 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found