sorting 1.2.0

The world's best, finest and inefficient sorting algorithms.
Documentation
  • Coverage
  • 100%
    19 out of 19 items documented1 out of 1 items with examples
  • Size
  • Source code size: 33.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 566.6 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Feliix42/sorting-rs
    17 3 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Feliix42

This crate provides an implementation of various quality sorting methods. Only the most useless or inefficient sorting algorithms are implemented. You may use them in your production application, altough I would strongly advise against that. Currently, the following sorting algorithms are implemented:

Panicsort

This sorting method kind of follows the principle of check and surrender and simply panics when the array or vector is not sorted:

# use sorting::*;
let unsorted = vec![5, 7, 8, 2, 1, 0];
unsorted.panicsort();   // will panic

Slowsort

This sorting algorithm recursively sorts the input array by finding the maximum of the sorted array, placing that maximum at the end and sorting the remaining array.

# use sorting::*;
let mut unsorted = vec![5, 7, 8, 2, 1, 0];
unsorted.slowsort();

Bogosort

This highly inefficient algorithm scrambles the input vector until it is sorted. Depending on your luck and the length of the input vector this might never return.

# use sorting::*;
let mut unsorted = vec![5, 7, 8, 2, 1, 0];
unsorted.bogosort();    // might take a while...

Sleepsort

This algorithm uses the operating system's scheduler for sorting by putting every value into its own thread and putting that thread to sleep for a time determined by the value.

# // This takes over two minutes to test, so we exclude it from normal test runs
# use sorting::*;
let unsorted = vec![5i8, -7, 8, 2, 1, 0, -9];
let sorted: Vec<_> = unsorted.sleepsort().collect();

Miraclesort

A sorting algorithm that waits for a miracle that automatically makes your vector sorted. Does nothing on its own.

# //don't run tests for this. Miracles don't happen all the time!
# use sorting::*;
let unsorted = vec![5i8, -7, 8, 2, 1, 0, -9];
let sorted: Vec<_> = unsorted.miraclesort();