Thanks to visit codestin.com
Credit goes to lib.rs

8 releases

Uses new Rust 2024

0.1.14 Sep 4, 2025
0.1.13 Sep 4, 2025
0.1.12 Jul 29, 2025

#955 in Algorithms

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

261 downloads per month

MIT license

12KB
233 lines

sorting-algorithm

various sorting algorithms implemented in Rust

The current implemented sorting algorithms are:

  • Bogo Sort
  • Bubble Sort
  • Cocktail Shaker Sort
  • Comb Sort
  • Gnome Sort
  • Heap Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Selection Sort
  • Shell Sort

Use

The use for each algorithm is essentially the same.

  1. Import the module for the desired algorithm
  2. Call the module's sort() function
  3. Pass a mutable pointer as an argument
use sorting_algorithm::bubble_sort;

fn main() {
    let &mut data = [3, 1, 2, 5, 4];

    bubble_sort::sort(&mut data);

    assert_eq!(data, [1, 2, 3, 4, 5]);
}

Dependencies

~27KB