Crates.io | sort |
lib.rs | sort |
version | 0.8.5 |
source | src |
created_at | 2014-11-22 23:29:38.464082 |
updated_at | 2021-07-12 05:31:09.061885 |
description | sort algorithms |
homepage | https://github.com/WatchDG/rust-sort |
repository | https://github.com/WatchDG/rust-sort |
max_upload_size | |
id | 360 |
size | 13,593 |
sort algorithms
extern crate sort;
use sort::bubble_sort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
bubble_sort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::quicksort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
quicksort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::selection_sort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
selection_sort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::heapsort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
heapsort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::insertion_sort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
insertion_sort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::merge_sort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
let result = merge_sort(&mut data);
assert_eq!(result, [1, 2, 3, 4, 5]);
}
extern crate sort;
use sort::introsort;
fn main() {
let mut data = vec![5, 4, 3, 2, 1];
introsort(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5]);
}