Function sort_steps::shell_sort_by

source ·
pub fn shell_sort_by<T, F>(v: &[T], compare: F) -> impl Iterator<Item = Vec<T>>where
    F: Fn(&T, &T) -> Option<Ordering> + Copy,
    T: Clone,
Expand description

Sorts a slice of data using the shell sort algorithm with a custom comparator.

Examples

let numbers = [5, 9, 3, 6, 8, 2, 1, 7, 4];
println!("Shell Sort Steps:");
for (i, v) in shell_sort_by(&numbers, |a, b| a.partial_cmp(b)).enumerate() {
    println!("#{:02}: {:?}", i, v);
}