Expand description
§Atrocious sort
Atrocious sort is a collection of some of the most useless sorting algorithms. The different algorithms depend on different traits to be implemented for the types that are to be sorted. The traits are specified in the documentation of each algorithm.
Implemented algorithms can only sort in ascending order.
§Algorithms
Currently implemented algorithms
- Stalinsort
- Intelligent Design Sort
- Sleep Sort
- Bogo Sort
- Bogobogo Sort
- Stooge Sort
§Examples
extern crate atrocious_sort;
use atrocious_sort::stalinsort;
fn main() {
let mut data = vec![1, 2, 3, 2, 1];
stalinsort(&mut data);
assert_eq!(data, [1, 2, 3]);
}
Modules§
- bogo_
sort - Are you feeling lucky today?
- bogobogo_
sort - Because bogo sort is to efficient, right?
- intelligent_
design_ sort - Praise the Sorter!
- sleep_
sort - What is an eternity anyway?
- slowsort
- Take your time. Get some coffee, start a family.
- stalinsort
- Is a capitalist spy hiding in your data?
- stoogesort
Functions§
- bogo_
sort - Creates a random permutation of the array until one happens to be sorted. The longer the array the longer of a brake you can take while you wait for it to be sorted.
- bogobogo_
sort - Sorts subarrays of increasing length 2, 3, 4, etc. using bogo sort. Should at any point any one of these subarrays not be sorted on the first try, the entire process will be restarted.
- intelligent_
design_ sort - Does not iterate over the vector. Does not modify the vector in any way. By the design of the Sorter all elements are already exactly where they should be. To tamper with this blessed order would be nothing short of heresy! Do not despair if you cannot yet comprehend the purpose of the order the Sorter has envisioned for you data. In time you shall find enlightenment and understanding.
- sleep_
sort - Each item in the vector is assigned to a new thread. Each thread will sleep for a number of seconds determined by the value of the item. Once a thread wakes up it will push the assigned item to a new vector which will be returned once all threads are done. Whenever that will be. Be aware that due to quirks with sleeping behavior and short delays when spawning the individual threads, the result is unreliable. In case of doubt just run it again.
- slowsort
- Splits the vector into two parts in the middle. Each half is then sorted recursively. Then the last element from both halfs are compared and the largest will be moved to the end of the vector. The procedure is then repeated for the rest of the vector excluding the last element.
- stalinsort
- Iterates over the vector and removes all elements that are out of order. If an element in the vector is out of order it is most likely a filthy capitalist saboteur keeping your honest and hard working data from being in order. The given vector will be modified in place.
- stoogesort
- Swaps the first and the last element if they are not in order. It will then sort the first two thirds of the array, then the second to thirds and then the first two thirds again.