http://qs321.pair.com?node_id=581298


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