Crate sort_steps

source ·
Expand description
#[test]
fn sort_step_by_step() {
    let numbers = [5, 9, 3, 6, 8, 2, 1, 7, 4];
    println!("Bubble Sort Steps:");
    for (i, v) in bubble_sort(&numbers).enumerate() {
        println!("#{}: {:?}", i, v);
    }
    println!("Insertion Sort Steps:");
    for (i, v) in insertion_sort(&numbers).enumerate() {
        println!("#{}: {:?}", i, v);
    }
    println!("Pancake Sort Steps:");
    for (i, v) in pancake_sort(&numbers).enumerate() {
        println!("#{}: {:?}", i, v);
    }
}

#[test]
fn bogo_step_by_step() {
    let numbers = [3, 4, 1, 2, 5];
    println!("Bogo Sort Steps:");
    for (i, v) in bogo_sort(&numbers).enumerate() {
        println!("#{}: {:?}", i, v);
    }
}

Functions

  • Sorts a slice of data using the bogo sort in O(n!).
  • Sorts a slice of data using the bogo sort with a custom comparator.
  • Sorts a slice of data using the bubble sort in O(n^2).
  • Sorts a slice of data using the bubble sort with a custom comparator.
  • Sorts a slice of data using the cocktail sort algorithm.
  • Sorts a slice of data using the cocktail sort algorithm with a custom comparator.
  • Sorts a slice of data using the comb sort algorithm.
  • Sorts a slice of data using the cocktail sort algorithm with a custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the gnome sort algorithm with a custom comparator.
  • Sorts a slice of data using the gnome sort algorithm with a custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the insertion sort algorithm with a custom comparator.
  • Sorts a slice of data using the insertion sort algorithm with a custom comparator.
  • Sorts a slice of data using the merge sort algorithm with a custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the pancake sort algorithm with a custom comparator.
  • Sorts a slice of data using the pancake sort algorithm with a custom comparator.
  • Sorts a slice of data using the quick sort in O(n×log(n)).
  • Sorts a slice of data using the quick sort with custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the heap sort algorithm with a custom comparator.
  • Sorts a slice of data using the shell sort algorithm.
  • Sorts a slice of data using the shell sort algorithm with a custom comparator.
  • Sorts a slice of data using the stooge sort algorithm with a custom comparator.
  • Sorts a slice of data using the stooge sort algorithm with a custom comparator.