Ver Fonte

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.
Corey Ford há 11 anos atrás
pai
commit
ee20c5d8bb
1 ficheiros alterados com 3 adições e 8 exclusões
  1. 3 8
      src/options.rs

+ 3 - 8
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)),