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

オープン
#16,690 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cli, rust
領域
cli, localization

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
24.4k
フォーク
2.2k
平均マージ
2日 23時間
マージ済み PR(30日)
402

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。