diff options
author | Corey Ford <corey@coreyford.name> | 2015-02-21 21:37:59 -0800 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-02-23 00:06:43 +0000 |
commit | ee20c5d8bb1fdf0eae381a76218aae2e2ae78546 (patch) | |
tree | 76932fd4ad223df036b046d6b0da47b8ee9bd8ab /src/options.rs | |
parent | ae39d0f8a79f1710c243202b6b695adfa843a430 (diff) |
Fix --sort=ext
The logic of the previous version wasn't correct. Also, presuming
natural ordering of full filenames is still reasonable when the
extensions are identical.
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/options.rs b/src/options.rs index 115a375..749d60c 100644 --- a/src/options.rs +++ b/src/options.rs @@ -5,7 +5,6 @@ use column::Column::*; use output::{Grid, Details}; use term::dimensions; -use std::ascii::AsciiExt; use std::cmp::Ordering; use std::fmt; @@ -118,13 +117,9 @@ impl FileFilter { SortField::Name => files.sort_by(|a, b| natord::compare(&*a.name, &*b.name)), SortField::Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)), SortField::FileInode => files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)), - SortField::Extension => files.sort_by(|a, b| { - if a.ext.cmp(&b.ext) == Ordering::Equal { - Ordering::Equal - } - else { - a.name.to_ascii_lowercase().cmp(&b.name.to_ascii_lowercase()) - } + SortField::Extension => files.sort_by(|a, b| match a.ext.cmp(&b.ext) { + Ordering::Equal => natord::compare(&*a.name, &*b.name), + order => order }), SortField::ModifiedDate => files.sort_by(|a, b| a.stat.modified.cmp(&b.stat.modified)), SortField::AccessedDate => files.sort_by(|a, b| a.stat.accessed.cmp(&b.stat.accessed)), |