Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Sorting a File which contains numbers

by Hofmator (Curate)
on Oct 30, 2006 at 14:11 UTC ( #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
Node Status?
node history
Node Type: note [id://581298]
help
Chatterbox?
[james28909]: i figured it out
[james28909]: upon trying various solutions, i was forgetting to package up the script into an executable
[marto]: that'll do it
[james28909]: im glad im not in charge of anything important, like filling up peanut butter jars
marto grins

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-07-28 14:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.