Skip to content

Instantly share code, notes, and snippets.

@davidpdrsn
Last active April 14, 2018 11:19
Show Gist options
  • Select an option

  • Save davidpdrsn/14dfbcfbc9fe0f9fc38613a4736506f8 to your computer and use it in GitHub Desktop.

Select an option

Save davidpdrsn/14dfbcfbc9fe0f9fc38613a4736506f8 to your computer and use it in GitHub Desktop.
use std::{fs::File, io::prelude::*};
fn main() {
let mut file = File::open("numbers.txt").unwrap();
let mut s = String::new();
file.read_to_string(&mut s).unwrap();
let mut acc: Vec<i32> = s.lines().map(|line| line.parse().unwrap()).collect();
acc.sort_unstable();
acc.iter().take(10).for_each(|n| println!("{}", n));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment