[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: confusion with sort
From: |
Bob Proulx |
Subject: |
Re: confusion with sort |
Date: |
Wed, 2 Apr 2008 23:49:39 -0600 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Kam-Hung Soh wrote:
> Mickey Ferguson wrote:
> > Notice the subtle difference: The lines at .957 are not in the same order
> > as in the original file.
Right. But notice that it is sorted according to the criteria given.
Within the sort keys the result is a sorted output.
Let me provide some rationale for this. A typical use for sort is to
produce a canonical form of the file so that multiple inputs can be
compared. If you had multiple input files with different orderings
then sort by default will sort them into a canonical form and then
they should all compare the same. If it stopped short of this then
the reverse problem would occur where multiple files wouldn't compare
the same after sorting.
> > Apparently my sort is just sorting the entire
> > line, instead of limiting the sort determination to the first twelve
> > characters. What am I doing wrong?
>
> Try adding the "-s" option, which "... disables this last-resort
> comparison so that lines in which all fields compare equal are left in
> their original relative order."
That should fix things for you.
Bob