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

Abierto
#16,690 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cli, rust
Área
cli, localization

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
24.4k
Forks
2.2k
Merge medio
2 d 23 h
PR fusionados (30 d)
402

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de uutils/coreutils

Todos los issues de uutils/coreutils

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.