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
Sorts a slice using the elements' natural ordering and returns the number of writes made.
Sorts a slice using a comparator function and returns the number of writes made.
Sorts a slice with a key extraction function and returns the number of writes made.