Subject: Re: bug#12907: Possible Bug in sort core utility

From: Bob Proulx <[email-masked]>
Date: Fri, 16 Nov 2012 11:59:17 -0700

tag 12907 + moreinfo
thanks

Coffey, Terrence (Terrence) **CTR** wrote:
> I think I might have located a bug. I'm using Redhat 6.3.

What locale are you using?  You can print out your locale settings
with the locale command.

  $ locale

Very often the locale is set to a "human" locale where case is folded
and punctuation is ignored in "dictionary" style.  This ordering is a
libc system library definition.

> I'm try to get a listing of dot file sorted by date and all other
> files sorted by date. I'd like all the dot file to appears before
> all other files.

I personally would do this with two different commands.  First list
the dot files using shell file glob matching only dot files.  Second
list non-dot files.  I would also use the --time-style=long-iso format
so that the dates are printed consistently.

  $ ls -Ald /tmp/.[!.]* ; ls -Ald /tmp/*

But I realize that sets different columns for the two different commands.

> Initially I was testing on 6.2 and noticed that the .(dot) files
> were not passed to sort. However this issue is fixed in 6.3.

I have no idea what you are talking about.  I don't recall any bug in
that area.  And if it is there then bringing up a fixed bug muddies
the water.

> However it does not appear to be able to sort dot files. The
> filename is key 11

In your example the filename is key 10 not 11.

  0 -rw-------. 1 root   root      0 Nov  9 15:06 yum.log
  1 2           3 4      5         6 7    8 9     10

That might be the most of your problem.

> If you need some additional data, just let me know.

Try this:

  $ ls -Asl --time-style=long-iso / | env LC_ALL=C sort -k9,9 -k7,8

Then please report back in if your problem is resolved.  Please keep
the bug log in the recipient list.

See also the FAQ entry:

  http://www.gnu.org/software/coreutils/faq/#Sort-does-not-sort-in-normal-order_0021

Bob