Function sort_steps::bubble_sort
source · pub fn bubble_sort<T>(v: &[T]) -> impl Iterator<Item = Vec<T>>where
T: PartialOrd + Clone,Expand description
Sorts a slice of data using the bubble sort in O(n^2).
Examples
let numbers = [5, 9, 3, 6, 8, 2, 1, 7, 4];
println!("Bubble Sort Steps:");
for (i, v) in bubble_sort(&numbers).enumerate() {
println!("#{:02}: {:?}", i, v);
}