bug-textutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in sort


From: Thomas Herchenroeder
Subject: Bug in sort
Date: Tue, 08 Jan 2002 17:17:20 +0000

Sorting months (option 'M') with character positions only works in the first 
field.

  root# sort --version
  sort (GNU textutils) 2.0
  Written by Mike Haertel.

  Copyright (C) 1999 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The data:

  root# cat test3
  02 Jan
  02 Jul
  02 Aug
  02 Feb
  02 Nov
  02 Mar
  02 Sep
  02 Jun
  02 Dec
  02 Oct
  02 May
  02 Apr

Sorting it on the month values does not work with character positions (sorting
is done lexically):

  root# sort -k 2.1,2.3M test3
  02 Apr
  02 Aug
  02 Dec
  02 Feb
  02 Jan
  02 Jul
  02 Jun
  02 Mar
  02 May
  02 Nov
  02 Oct
  02 Sep

The same thing with the month data in the first field works:

  root# cut -d" " -f2 test3 | sort -k 1.1,1.3M
  Jan
  Feb
  Mar
  Apr
  May
  Jun
  Jul
  Aug
  Sep
  Oct
  Nov
  Dec

Sorting test3 on the whole second field works fine (e.g. sort -2,2M test3). But
of course I need it for data where character positioning is necessary (e.g.
where I have something like "#Jan#"). This example is only to be as simple as
possible.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]