Skip to content

WatchDG/rust-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-sort

sort algorithms

exchange sorts

bubble sort

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]);
}

quicksort

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]);
}

selection sorts

selection sort

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]);
}

heapsort

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]);
}

insertion sorts

insertion sort

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]);
}

merge sorts

merge sort

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]);
}

hybrid sorts

introsort

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]);
}

About

sort algorithms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages