thag_rs 0.2.1

A versatile cross-platform playground and REPL for Rust snippets, expressions and programs. Accepts a script file or dynamic options.
Documentation
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<_>>());
}