mirror of
https://github.com/icewind1991/zox
synced 2026-06-03 18:34:07 +02:00
sort output of -l
This commit is contained in:
parent
982966d023
commit
b783a8792d
1 changed files with 9 additions and 9 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -170,20 +170,20 @@ fn main() -> Result<(), MainError> {
|
|||
if let Ok(history) = history_result {
|
||||
let matches = history.filter(|item| item.matches(&args.filter));
|
||||
|
||||
let mut matches: Vec<History> = matches.collect();
|
||||
matches.sort_by(
|
||||
|a, b| match a.get_sort(args.sort, now) - b.get_sort(args.sort, now) {
|
||||
diff if diff < 0.0 => Ordering::Greater,
|
||||
diff if diff > 0.0 => Ordering::Less,
|
||||
_ => Ordering::Equal,
|
||||
},
|
||||
);
|
||||
|
||||
if args.list {
|
||||
for item in matches {
|
||||
println!("{:<11}{}", item.get_sort(args.sort, now), item.path);
|
||||
}
|
||||
} else {
|
||||
let mut matches: Vec<History> = matches.collect();
|
||||
matches.sort_by(
|
||||
|a, b| match a.get_sort(args.sort, now) - b.get_sort(args.sort, now) {
|
||||
diff if diff < 0.0 => Ordering::Greater,
|
||||
diff if diff > 0.0 => Ordering::Less,
|
||||
_ => Ordering::Equal,
|
||||
},
|
||||
);
|
||||
|
||||
if let Some(first) = matches.first() {
|
||||
println!("{}", first.path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue