On Mon 8-Jan-07 6:04pm -0600, Vigil 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?

> This works on my admittedly small test set:
>
>         :%!sort -k3 -t/

You're making several unstated assumptions.

(1) The records are already sorted by month and day.
(2) Your sort utility is stable.
(3) Everything to the right of the year is the same in each
    record.

Using the unix sort (this won't work with the Windows sort):

   :%!sort -t/ -k3.1n,3.4 -k1n,2

Here, the only assumption is that each record starts with a
date of the form:  mm/dd/yyyy

-- 
Best regards,
Bill

Reply via email to