Skip to content

Instantly share code, notes, and snippets.

Created July 3, 2015 23:56
Show Gist options
  • Save anonymous/8fdc8b4f969fc402657c to your computer and use it in GitHub Desktop.
Save anonymous/8fdc8b4f969fc402657c to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn main() {
let mut teams = [
[ ("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19), ],
[ ("Bill", 17), ("Brenda", 16), ("Brad", 18), ("Barbara", 17), ]
];
let teams_in_score_order = teams
.iter_mut()
.map(|team| {
team.sort_by(|&a, &b| a.1.cmp(&b.1));
team
})
.collect::<Vec<_>>();
println!("Teams: {:?}", teams_in_score_order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment