From 80a6cefbeb7fd0ab8b658fb1944d61c81c7339d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 3 Oct 2025 17:04:24 +0200 Subject: [PATCH] fix: sort items before chunking The chunk_by function works like coreutils sort in that it expects sorted inputs. --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 05c46e0..7796e07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,8 @@ async fn complete(mut channel: Channel, client: &Client) -> Result> let grouped: Vec> = channel .items() .iter() - .chunk_by(|item| get_domain(item)) + .sorted_by(|a, b| get_domain(a).cmp(&get_domain(b))) + .chunk_by(|&item| get_domain(item)) .into_iter() .map(|(_k, v)| v.cloned().collect()) .collect();