sort: add locale-aware month sorting (-M)#11445
Conversation
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
3377348 to
aa3ca32
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
146a915 to
afbe750
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
tests/by-util/test_sort.rs
Outdated
| let expected = months.iter().fold(String::new(), |mut s, m| { | ||
| writeln!(s, "{m}").unwrap(); | ||
| s | ||
| }); |
There was a problem hiding this comment.
Using join might be easier to read:
| let expected = months.iter().fold(String::new(), |mut s, m| { | |
| writeln!(s, "{m}").unwrap(); | |
| s | |
| }); | |
| let expected = months.join("\n") + "\n"; |
src/uu/sort/src/sort.rs
Outdated
| let initial_selection = &self.line[selection.clone()]; | ||
|
|
||
| let mut month_chars = initial_selection | ||
| let trimmed = initial_selection |
There was a problem hiding this comment.
The name trimmed is a bit misleading as it contains a position (and not a trimmed string).
src/uu/sort/src/sort.rs
Outdated
| trimmed..trimmed | ||
| } else { | ||
| // We parsed a month. Match the first three non-whitespace characters, which must be the month we parsed. | ||
| month_chars.next().unwrap().0 | ||
| ..month_chars | ||
| .nth(2) | ||
| .map_or(initial_selection.len(), |(idx, _)| idx) | ||
| // We parsed a month. Use the actual match byte length. | ||
| trimmed..(trimmed + match_len) |
There was a problem hiding this comment.
It might make sense to set selection.start and selection.end directly in the if/else blocks instead of returning a range.
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
fix: tests/sort/sort-month.sh
|
GNU testsuite comparison: |
Kudos! |
No description provided.