def cycle_sort(arr):
len_arr = len(arr)<EOL>for cur in range(len_arr - <NUM_LIT:1>):<EOL><INDENT>item = arr[cur]<EOL>index = cur<EOL>for i in range(cur + <NUM_LIT:1>, len_arr):<EOL><INDENT>if arr[i] < item:<EOL><INDENT>index += <NUM_LIT:1><EOL><DEDENT><DEDENT>if index == cur:<EOL><INDENT>continue<EOL><DEDENT>while item == arr[index]:<EOL><INDENT>index += <NUM_LIT:1><EOL><DEDENT>arr[index], item = item, arr[index]<EOL>while index != cur:<EOL><INDENT>index = cur<EOL>for i in range(cur + <NUM_LIT:1>, len_arr):<EOL><INDENT>if arr[i] < item:<EOL><INDENT>index += <NUM_LIT:1><EOL><DEDENT><DEDENT>while item == arr[index]:<EOL><INDENT>index += <NUM_LIT:1><EOL><DEDENT>arr[index], item = item, arr[index]<EOL><DEDENT><DEDENT>return arr<EOL>
cycle_sort
This is based on the idea that the permutations to be sorted
can be decomposed into cycles,
and the results can be individually sorted by cycling.

reference: https://en.wikipedia.org/wiki/Cycle_sort

Average time complexity : O(N^2)
Worst case time complexity : O(N^2)