mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
parent
38300a818e
commit
2238c07b91
1 changed files with 7 additions and 16 deletions
|
@ -1,5 +1,4 @@
|
||||||
use crate::env::environment::Environment;
|
use crate::env::environment::Environment;
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::fs::Metadata;
|
use std::fs::Metadata;
|
||||||
use std::os::unix::prelude::{FileTypeExt, MetadataExt};
|
use std::os::unix::prelude::{FileTypeExt, MetadataExt};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
@ -716,14 +715,10 @@ fn path_sort(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Op
|
||||||
let mut list: Vec<_> = arguments.map(|(f, _)| f).collect();
|
let mut list: Vec<_> = arguments.map(|(f, _)| f).collect();
|
||||||
|
|
||||||
if opts.key.is_some() {
|
if opts.key.is_some() {
|
||||||
// We use a stable sort here
|
// sort_by is stable
|
||||||
list.sort_by(|a, b| {
|
list.sort_by(|a, b| match wcsfilecmp_glob(keyfunc(a), keyfunc(b)) {
|
||||||
match wcsfilecmp_glob(keyfunc(a), keyfunc(b)) {
|
|
||||||
// to avoid changing the order so we can chain calls
|
|
||||||
Ordering::Equal => Ordering::Greater,
|
|
||||||
order if opts.reverse => order.reverse(),
|
order if opts.reverse => order.reverse(),
|
||||||
order => order,
|
order => order,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if opts.unique {
|
if opts.unique {
|
||||||
|
@ -733,13 +728,9 @@ fn path_sort(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Op
|
||||||
} else {
|
} else {
|
||||||
// Without --key, we just sort by the entire path,
|
// Without --key, we just sort by the entire path,
|
||||||
// so we have no need to transform and such.
|
// so we have no need to transform and such.
|
||||||
list.sort_by(|a, b| {
|
list.sort_by(|a, b| match wcsfilecmp_glob(a, b) {
|
||||||
match wcsfilecmp_glob(a, b) {
|
|
||||||
// to avoid changing the order so we can chain calls
|
|
||||||
Ordering::Equal => Ordering::Greater,
|
|
||||||
order if opts.reverse => order.reverse(),
|
order if opts.reverse => order.reverse(),
|
||||||
order => order,
|
order => order,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if opts.unique {
|
if opts.unique {
|
||||||
|
|
Loading…
Reference in a new issue