Sort(1) on E-format numerics

Greg "Bucket" Woods woods at hao.UUCP
Fri Sep 28 05:08:15 AEST 1984


  We have a need to numerically sort files which contain columns of numbers in
E-format, i.e. something of the form [+-]#.####e[+-]##, where "#" means
a digit and [+-] means an optional sign. Unfortunately, the -n option to
sort(1) does not recognize exponents and stops numerical conversion of the
sort field when it sees the "e". This results in incorrect sorting in some
cases, like it will put 1.0e-07 before 2.0e-09. 
  So, before I go through the hassle of hacking the source code for sort(1),
or writing another whole program to do this, I'd like to know if anyone else
has already invented this wheel. Has anyone hacked sort(1) to do this correctly?
I will settle for any kludges that would work with existing programs as well.
Various thoughts of running sort(1) twice have crossed my mind, but I have
yet to come up with anything that will work reliably in all cases. Any ideas?
  Please *mail* me any hints. If someone comes up with an answer, I will post
it to the net. We are running 4.2BSD on a VAX 11/750, in case that matters.

--Greg
-- 
{ucbvax!hplabs | allegra!nbires | decvax!stcvax | harpo!seismo | ihnp4!stcvax}
       		        !hao!woods
   
     "  She could make happy, any man alive..."



More information about the Comp.unix mailing list