From 0decad55867247c3f90ad3419cceb8a9d1ca5e2a Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 1 Dec 2023 12:51:56 +0100 Subject: [PATCH] cli: Fix sorting of `rad sync status` --- radicle-cli/src/commands/sync.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 55b7e143..c6031128 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -578,7 +578,12 @@ fn sort_seeds_by(local: NodeId, seeds: &mut [Seed], aliases: &impl AliasStore, s let b = aliases.alias(&b.nid); a.cmp(&b) } - SortBy::Status => a.sync.cmp(&b.sync), + SortBy::Status => match (&a.sync, &b.sync) { + (Some(_), None) => Ordering::Less, + (None, Some(_)) => Ordering::Greater, + (Some(a), Some(b)) => a.cmp(b).reverse(), + (None, None) => Ordering::Equal, + }, }; // Always show our local node first. @@ -588,13 +593,7 @@ fn sort_seeds_by(local: NodeId, seeds: &mut [Seed], aliases: &impl AliasStore, s } else if b.nid == local { Ordering::Greater } else { - match (&a.sync, &b.sync) { - (Some(_), None) => Ordering::Less, - (None, Some(_)) => Ordering::Greater, - (Some(a), Some(b)) => a.cmp(b).reverse(), - (None, None) => Ordering::Equal, - } - .then(compare(a, b)) + compare(a, b) } }); }