Function buldak::bitonic::sort_by

source ·
pub fn sort_by<T, F>(array: &mut [T], compare: F) -> Result<(), String>
where T: Ord, F: Fn(&T, &T) -> Ordering + Clone,
Expand description

It takes a comparator function to determine the order, and sorts it using a bitonic sort algorithm.

use buldak::bitonic;

let mut nums = [1, 4, 2, 3, 5, 111, 234, 21];
bitonic::sort_by(&mut nums, |l, r| l.cmp(r));
assert_eq!(nums, [1, 2, 3, 4, 5, 21, 111, 234]);