On 2007-01-05, Bill McCarthy <[EMAIL PROTECTED]> wrote:
> On Fri 5-Jan-07 1:04pm -0600, Gary Johnson wrote:
> 
> > On 2007-01-05, Erlend Hamberg <[EMAIL PROTECTED]> wrote:
> >> On Friday 05 January 2007 15:47, striker wrote:
> >> > I have a text file in the format:
> >> > 01/04/2007,field1,field2,field3
> >> > 01/03/2007,field1,field2,field3
> >> > 12/30/2006,field1,field2,field3
> >> > etc...
> >> >
> >> > I need to sort by date, but the new dates in 2007 are placed first in
> >> > the sort algorithm.  How can I sort by the entire date in the format
> >> > above?
> >> 
> >> :%sort n /\d\+\/\d\+/
> 
> > To sort by the entire date, this needs to be a two-stage process.
> > First do an ordinary (not numeric) sort on the whole line:
> >
> >     :%sort
> >
> > Then do a sort (numeric or ordinary) ignoring the month and day
> > fields, as Erlend suggested:
> >
> >     :%sort n /\d\+\/\d\+/
> 
> That would work if the sort were stable.  It isn't in native
> Windows.  The following will fail to sort with earliest date
> last:
> 
>     :%sort!
>     :%sort! n /\d\+\/\d\+/

Bummer.  I thought it was stable--it appeared to be whenever I used 
it on a Unix system--and that the algorithm was completely internal 
to vim.  Having now actually read ":help sort", I see that you're 
right.  Thanks for pointing that out.

Regards,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA

Reply via email to