On 07/10/2022 03:15, Rudolf Adamkovič wrote:

If I understand, "a" should be less than "B" when under "C" locale when
ignoring case (nil) , right?  Yet, I get the following:

(string-collate-lessp "a" "B" "C" nil)  ; => nil

When case is not ignored (4th argument is nil) locale-dependent collation rules are used, so you get the expected result.

$ printf 'a\nB\n' | LC_COLLATE=C sort
B
a
$ printf 'a\nB\n' | LC_COLLATE=en_US.UTF-8 sort
a
B

[FYI: If I replace nil with t, the procedure returns nil too.]

Tested on Emacs 29 (adaa2fc90e) and Org 9.5.5 (580f28614).

Strange. Emacs-26, Linux

(string-collate-lessp "a" "B" "C" t)
t

If libc is sane (assuming that sort is linked to the same libc)

printf 'a\nb\n' | LC_COLLATE=C sort
printf 'b\na\n' | LC_COLLATE=C sort
printf 'A\nB\n' | LC_COLLATE=C sort
printf 'B\nA\n' | LC_COLLATE=C sort
printf 'a\nb\n' | LC_COLLATE=C.UTF-8 sort
printf 'b\na\n' | LC_COLLATE=C.UTF-8 sort
printf 'A\nB\n' | LC_COLLATE=C.UTF-8 sort
printf 'B\nA\n' | LC_COLLATE=C.UTF-8 sort

then you might face an Emacs bug.

P.S. Example of a subtle issue with sorting: significant space added to some locales like es_ES & Co, pl_PL:

Maxim Nikulin. Re: [Patch] to correctly sort the items with emphasis marks in a list. Fri, 16 Apr 2021 21:59:51 +0700. https://list.orgmode.org/s5c8p9$97n$1...@ciao.gmane.io


Reply via email to