From 458dc3150c72e267674bd447a1710c4bb104e554 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 6 Jan 2026 01:27:06 +0900 Subject: [PATCH] rwho: sort entries --- src/bin/rwho.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/rwho.rs b/src/bin/rwho.rs index 2cf4621..72ce4e8 100644 --- a/src/bin/rwho.rs +++ b/src/bin/rwho.rs @@ -34,12 +34,19 @@ async fn main() -> anyhow::Result<()> { .await .expect("Failed to connect to rwhod server"); - let reply = conn + let mut reply = conn .rwho(args.all) .await .context("Failed to send rwho request")? .map_err(|e| anyhow::anyhow!("Server returned an error for rwho request: {:?}", e))?; + reply.sort_by(|(host, user), (host2, user2)| { + user.user_id + .cmp(&user2.user_id) + .then_with(|| host.cmp(host2)) + .then_with(|| user.tty.cmp(&user2.tty)) + }); + if args.json { println!("{}", serde_json::to_string_pretty(&reply).unwrap()); } else if args.old {