fix: sort items before chunking

The chunk_by function works like coreutils sort in that it expects
sorted inputs.
This commit is contained in:
Moritz Böhme 2025-10-03 17:04:24 +02:00
parent 0f08e877e4
commit 80a6cefbeb
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9

View file

@ -27,7 +27,8 @@ async fn complete(mut channel: Channel, client: &Client) -> Result<Box<Channel>>
let grouped: Vec<Vec<rss::Item>> = channel let grouped: Vec<Vec<rss::Item>> = channel
.items() .items()
.iter() .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() .into_iter()
.map(|(_k, v)| v.cloned().collect()) .map(|(_k, v)| v.cloned().collect())
.collect(); .collect();