Subject: bug#59275: Unexpected return value of `string-collate-lessp' on Mac

From: Eli Zaretskii <[email-masked]>
Date: Mon, 21 Nov 2022 15:31:38 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 21 Nov 2022 07:28:55 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> Reliable sorting.
> >> In particular, I am looking for a better PREDICATE argument for
> >> `sort-subr' for case-sensitive and case-insensitive sorting of strings.
> >
> > In the strict order of Unicode codepoints?  Use compare-strings.
> 
> Thanks for the clarification.
> After further considerations, it looks like we should still use
> `string-collate-lessp' on Org side as it yields expected results if libc
> properly implements the collation.

Is the feature that uses it intended to be used only on glibc platforms
(which basically means GNU/Linux)?  If not, I'm surprised that you arrived
at this conclusion.  It is the 180 deg opposite of what I think you should
have decided.

Once again: locale-specific collation order is inherently unpredictable in
its results, and should only be used when the locale-specific order is a
_must_, like when sorting people's names for a telephone directory.

> Maybe change
> 
>   If your system does not support a locale environment, this function
>   behaves like `string-lessp'.
> 
> to
> 
>   Some operating systems do not implement correct collation (in specific
>   locale environments or at all). Then, this functions falls back to
>   case-sensitive `string-lessp' and IGNORE-CASE argument is ignored.

Fine with me.