Skip to content

Instantly share code, notes, and snippets.

@kromych
Created July 18, 2020 05:18
Show Gist options
  • Select an option

  • Save kromych/5f40609e8f7ec9a23d43edd5ec1af16e to your computer and use it in GitHub Desktop.

Select an option

Save kromych/5f40609e8f7ec9a23d43edd5ec1af16e to your computer and use it in GitHub Desktop.

Revisions

  1. kromych created this gist Jul 18, 2020.
    20 changes: 20 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    use std::fs::{read_to_string, File};
    use std::io::{BufWriter, Error, Write};
    use std::time::Instant;

    fn main() -> Result<(), Error> {
    let now = Instant::now();

    let wordlist = read_to_string("randomized.txt")?;
    let mut list: Vec<&str> = wordlist.split_ascii_whitespace().collect();

    list.sort_unstable();

    let mut writer = BufWriter::new(File::create("rust_sorted.txt")?);
    writer.write(list.join("\n").as_bytes())?;

    let elapsed = now.elapsed().as_micros();
    println!("Took {} microseconds", elapsed);

    Ok(())
    }