cycle_sort/
lib.rs

1#![deny(missing_docs)]
2#![no_std]
3
4//! Simple Cycle sort implementation.
5//!
6//! Cycle sort is an unstable comparison sort that minimizes the
7//! number of writes. It has a best- and worst-case performance of
8//! `O(n^2)`, making it slow on large sets of data. It is useful when
9//! writes are expensive and want to be reduced.
10//!
11//! Because the algorithm performs in `O(n^2)` for sorted lists, you
12//! may want to consider checking if sorting is necessary before
13//! actually sorting.
14//!
15//! # Safety
16//!
17//! If the comparison function passed to [`cycle_sort_by`] or the key
18//! extraction function passed to [`cycle_sort_by_key`] panics, the
19//! data being sorted is likely to end up in an invalid state.
20//!
21//! [`cycle_sort_by`]: fn.cycle_sort_by.html
22//! [`cycle_sort_by_key`]: fn.cycle_sort_by_key.html
23
24mod cycle_sort;
25mod util;
26
27pub use crate::cycle_sort::{cycle_sort, cycle_sort_by, cycle_sort_by_key};