mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
fix ls
This commit is contained in:
parent
75a76613e4
commit
b465c34eef
2 changed files with 5 additions and 4 deletions
|
@ -1042,7 +1042,7 @@ fn sort_entries(entries: &mut Vec<PathBuf>, config: &Config) {
|
|||
.sort_by_key(|k| Reverse(get_metadata(k, config).map(|md| md.len()).unwrap_or(0))),
|
||||
// The default sort in GNU ls is case insensitive
|
||||
Sort::Name => entries.sort_by_key(|k| k.to_string_lossy().to_lowercase()),
|
||||
Sort::Version => entries.sort_by(version_cmp::version_cmp),
|
||||
Sort::Version => entries.sort_by(|a, b| version_cmp::version_cmp(a, b)),
|
||||
Sort::None => {}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use std::{cmp::Ordering, path::PathBuf};
|
||||
use std::cmp::Ordering;
|
||||
use std::path::Path;
|
||||
|
||||
/// Compare pathbufs in a way that matches the GNU version sort, meaning that
|
||||
/// Compare paths in a way that matches the GNU version sort, meaning that
|
||||
/// numbers get sorted in a natural way.
|
||||
pub(crate) fn version_cmp(a: &PathBuf, b: &PathBuf) -> Ordering {
|
||||
pub(crate) fn version_cmp(a: &Path, b: &Path) -> Ordering {
|
||||
let a_string = a.to_string_lossy();
|
||||
let b_string = b.to_string_lossy();
|
||||
let mut a = a_string.chars().peekable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue