sort: in UTF-8 locales, lines differing only in punctuation are ordered unlike GNU

Đang mở
#16,690 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cli, rust
Lĩnh vực
cli, localization

Hướng nghiên cứu

Start with init_locale_collation in src/uucore/src/lib/features/i18n/collator.rs and compare the ICU collation behavior with the GNU examples in the issue. Check related issues #12542, #12677, and #16237 for prior collation decisions. Done means punctuation ties follow GNU's order and sort -c accepts GNU-sorted input in the reported UTF-8 locale.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

U - sort

In en_US.UTF-8, both sorts ignore punctuation at the first level, but they
break the tie differently:

$ printf "a.\na'\na-\n" | LC_ALL=en_US.UTF-8 sort

GNU (9.10, glibc 2.43):

a'
a-
a.

uutils (main, 293a724eb):

a-
a.
a'

With more punctuation, GNU's order is the code point order, and ours looks like
the CLDR/ICU order:

$ printf "a'\na-\na.\na,\na_\na!\na?\na:\na;\na/\n" | LC_ALL=en_US.UTF-8 sort | paste -sd' '
GNU:     a! a' a, a- a. a/ a: a; a? a_
uutils:  a_ a- a, a; a: a! a? a. a' a/

Because of this, sort -c disagrees with GNU on GNU-sorted input:

$ printf "a'\na-\na.\n" | LC_ALL=en_US.UTF-8 sort -c
sort: -:2: disorder: a-        # uutils, exit 1; GNU accepts it (exit 0)

On a real word list (/usr/share/dict/words), 19 lines end up in a different
place (e.g. a', A&M).

init_locale_collation (src/uucore/src/lib/features/i18n/collator.rs) uses
ICU with AlternateHandling::Shifted and Strength::Quaternary, so punctuation
is compared at the quaternary level, in ICU's order of variable characters.

Related: #12542 / #12677 (hyphen at the first level, fixed) and #16237 (symbols
at the first level). This one is about the order among punctuation once the
rest is equal.

Note: GNU takes its order from glibc's locale data. Checked 2026-11-18: same
code point order with GNU sort 9.4/glibc 2.39 (Ubuntu 24.04), 9.7/2.41 (Debian
trixie), 9.7/2.43 (Ubuntu 26.04 gnusort) and 9.10/2.43 (Fedora). Ubuntu 26.04's
default sort (uutils 0.10.0) gives our order.

Ngôn ngữ chính
Rust
Star
24.4k
Fork
2.2k
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
402

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/coreutils

Tất cả issue của uutils/coreutils

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.