diff --git a/src/uucore/src/lib/features/i18n/collator.rs b/src/uucore/src/lib/features/i18n/collator.rs index 9a8ee1fc6..fbb9e61f7 100644 --- a/src/uucore/src/lib/features/i18n/collator.rs +++ b/src/uucore/src/lib/features/i18n/collator.rs @@ -70,6 +70,7 @@ pub fn init_locale_collation() -> bool { // UTF-8 locale - initialize collator with Shifted mode to match GNU behavior let mut opts = CollatorOptions::default(); opts.alternate_handling = Some(AlternateHandling::Shifted); + opts.strength = Some(Strength::Quaternary); try_init_collator(opts) } diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index e9dc9bfa6..732b5c58b 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -3017,4 +3017,23 @@ fn test_consistent_sorting_with_i18n_collate() { .stdout_is(expected_output); } +#[test] +fn test_sort_locale_punctuation_weights() { + // Test for issue #12542 + let input = "file10\nfile-10\n"; + let expected_output = "file-10\nfile10\n"; + + new_ucmd!() + .env("LC_ALL", "en_US.UTF-8") + .pipe_in(input) + .succeeds() + .stdout_is(expected_output); + + new_ucmd!() + .env("LC_ALL", "C") + .pipe_in(input) + .succeeds() + .stdout_is(expected_output); +} + /* spell-checker: enable */