# cycle sort Algorithm

Cycle sort is an in-place, unstable sorting algorithm, a comparison sort that is theoretically optimal in terms of the total number of writes to the original array, unlike any other in-place sorting algorithm. This matches the minimal number of overwrites need for a completed in-place sort.
Minimizing the number of writes is useful when make writes to some huge data set is very expensive, such as with EEPROMs like flash memory where each write reduces the lifespan of the memory.

### cycle sort source code, pseudocode and analysis

This procedure of displace components to their correct positions continues until an component is moved to the original position of a. give an component a, we can find the index at which it will happen in the sorted list by simply counting the number of components in the entire list that are smaller than a.