use itertools::Itertools;
/// Demo sorting RGB tuples using `itertools`. Generated by ChatGPT.
//# Purpose: A simple demonstration.
//# Categories: crates, learning, technique
fn main() {
let colors = vec![
(255, 0, 0),
(0, 255, 0),
(0, 0, 255),
(128, 128, 128),
(255, 255, 0),
];
let sorted_colors = colors.into_iter().sorted_by(|a, b| {
a.0.cmp(&b.0) // First sort by R
.then_with(|| a.1.cmp(&b.1)) // Then by G
.then_with(|| a.2.cmp(&b.2)) // Then by B
});
println!("Sorted colors: {:?}", sorted_colors.collect::<Vec<_>>());
}