Subject: Re: bug#18051: 24.3.92; ls-lisp: Sorting; make ls-lisp-string-lessp a normal function?

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Jul 2014 13:56:02 +0300

> Date: Sat, 19 Jul 2014 11:17:15 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > > But if 'ls' supports that, so should ls-lisp.
> > 
> > It depends on "locale" settings.  I tried some settings of the LC_ALL
> > variable.  With "C" or "POSIX", I get the same sorting as with ls-lisp.
> > OTOH, with "en_US.utf8" or "de_DE.utf8" I get the sorting I described,
> > with dot files merged with the other files.
> 
> AFAICT, 'ls' uses strcoll.  I don't see how can that effectively
> ignore the leading dot, but maybe I'm missing something.

I think I know the answer: those versions of 'ls' that do this are
based on libc implementation that supports UTS#10, the Unicode
Collation Algorithm, or at least part of it.  UTS#10 specifies a
multi-level comparison, whereby base characters, accents, and
letter-case variants are compared before punctuation characters.

> OTOH, if the UTF-8 codeset says the leading dot should be ignored,
> then ls-lisp should do the same by default, at least when the
> locale's codeset is UTF-8.

For this, we would need a UTS#10 compatible compare-strings.  Then
ls-lisp could simply use it when the locale is .UTF-8.

Alternatively, we could have an approximation to that, just for
sorting non-punctuation characters before the punctuation characters.