# Crate cycle_sort [−] [src]

Simple Cycle sort implementation.

Cycle sort is an unstable comparison sort that minimizes the
number of writes. It has a best- and worst-case performance of
`O(n^2)`

, making it slow on large sets of data. It is useful when
writes are expensive and want to be reduced.

Because the algorithm performs in `O(n^2)`

for sorted lists, you
may want to consider checking if sorting is necessary before
actually sorting.

# Panics

If the comparison function passed to `cycle_sort_by`

or the key
extraction function passed to `cycle_sort_by_key`

panics, the
data being sorted is likely to end up in an invalid state.

## Functions

cycle_sort |
Sorts a slice using the elements' natural ordering and returns the number of writes made. |

cycle_sort_by |
Sorts a slice using a comparator function and returns the number of writes made. |

cycle_sort_by_key |
Sorts a slice with a key extraction function and returns the number of writes made. |