[][src]Function sorting_rs::oddeven_sort::oddeven_sort

pub fn oddeven_sort<T: PartialOrd>(input: &mut [T])

Sorts a slice in-place using Odd-even sort Sorts a slice in-place using Batcher Odd-even sort

All kinds of slices can be sorted as long as they implement PartialOrd.

It's a relatively simple algorithm developed originally for use on parallel processors with local interconnections.

Batcher algorithm is the enchanced version of odd-even algorithm

Examples

let mut vec = vec![5,3,2,4];
sorting_rs::oddeven_sort(&mut vec);
assert_eq!(vec, &[2,3,4,5]);
let mut strings = vec!["rustc", "cargo", "rustup"];
sorting_rs::oddeven_sort(&mut strings);
assert_eq!(strings, &["cargo", "rustc", "rustup"]);
let mut vec = vec![5,3,2,4];
sorting_rs::oddeven_batcher_sort(&mut vec);
assert_eq!(vec, &[2,3,4,5]);
let mut strings = vec!["rustc", "cargo", "rustup"];
sorting_rs::oddeven_batcher_sort(&mut strings);
assert_eq!(strings, &["cargo", "rustc", "rustup"]);