Crates.io | sort-rs |
lib.rs | sort-rs |
version | 0.1.2 |
source | src |
created_at | 2021-06-08 15:06:18.29827 |
updated_at | 2021-06-14 15:25:17.919228 |
description | A crate exposing sorting algorithms |
homepage | |
repository | https://github.com/siddharthborderwala/sort-rs/ |
max_upload_size | |
id | 407838 |
size | 8,590 |
A repository with various sorting algorithms
extern crate sort;
use sort::quick_sort;
fn main() {
let mut list_of_numbers = [4, 2, 7, 5, 1, 3];
quick_sort(&mut list_of_numbers);
assert_eq!(list_of_numbers, [1, 2, 4, 5, 7]);
}
extern crate sort;
use sort::insertion_sort;
fn main() {
let mut list_of_chars = ['s', 'y', 's', 't', 'e', 'm'];
insertion_sort(&mut list_of_chars)
assert_eq!(list_of_numbers, ['e', 'm', 's', 's', 't', 'y']);
}
$ cargo run -- <bubble|selection|insertion|merge|quick> <comma-separated list of integers>
For example
$ cargo run -- merge "12,54,33,27,19,23,44"
> [12, 19, 23, 27, 33, 44, 54]
Make sure you have rust-toolchain installed to build the executable
For windows only
$ ./release.sh
After you have built the executable, run the following
$ ./build/sorter.exe <algorithm-option> <comma-separated list of integers>