Crates.io | sort-it |
lib.rs | sort-it |
version | 0.2.2 |
source | src |
created_at | 2020-08-28 00:57:55.968947 |
updated_at | 2022-02-07 23:13:45.511737 |
description | Provides various sorting algorithms |
homepage | https://github.com/discobiscuit99/sort-it |
repository | https://github.com/discobiscuit99/sort-it |
max_upload_size | |
id | 281682 |
size | 55,201 |
This crate provides various different sorting algorithms both implemented directly on
any Vec
implementing certain things and also as standalone functions.
Using the trait implementations:
use sort_it::prelude::*;
fn main() {
let mut v = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
println!("original v: {:?}", v.clone());
v.gnome_sort(); // sorts `v` via gnome sort (with the trait implementation).
println!("sorted v: {:?}", v);
}
Without using the trait implementations:
use sort_it::prelude::*;
use rand::prelude::*;
fn main() {
let mut rng = rand::thread_rng();
let mut v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
v.shuffle(&mut rng); // randomly shuffles `v`.
let s = merge_sort(v.clone()); // returns a sorted copy of `v` via merge sort (without the trait implementation).
println!("v: {:?}, s: {:?}", v, s);
}
Have fun sorting things in different ways.