Keep in mind the "swap" that happens isn't an in-place swap within the list. It's a swap with a tmp variable, and this is required for the algorithm to work. This is why we need the caller to pass us a pointer to store the tmp value in. Otherwise we could just do a simple byte-wise swap.
https://en.wikipedia.org/wiki/Cycle_sort https://rosettacode.org/wiki/Sorting_algorithms/Cycle_sort#C
Keep in mind the "swap" that happens isn't an in-place swap within the list. It's a swap with a tmp variable, and this is required for the algorithm to work. This is why we need the caller to pass us a pointer to store the tmp value in. Otherwise we could just do a simple byte-wise swap.