Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Sorting a File which contains numbers

by Hofmator (Curate)
on Oct 30, 2006 at 14:11 UTC ( [id://581298]=note: print w/replies, xml ) Need Help??


in reply to Sorting a File which contains numbers

Watch out: sort sorts normally "in standard string comparison order" which is NOT numerically. In order to sort numerically, you have to use an explicit sort routine.

With your expamle input file, this won't make a difference though, as it sorts the same numerically AND alphabetically.

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re: Sorting a File which contains numbers

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581298]
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: (4)
As of 2024-04-24 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found