def insertion_sort(arr, simulation=False):
iteration = <NUM_LIT:0><EOL>if simulation:<EOL><INDENT>print("<STR_LIT>",iteration,"<STR_LIT::>",*arr)<EOL><DEDENT>for i in range(len(arr)):<EOL><INDENT>cursor = arr[i]<EOL>pos = i<EOL>while pos > <NUM_LIT:0> and arr[pos - <NUM_LIT:1>] > cursor:<EOL><INDENT>arr[pos] = arr[pos - <NUM_LIT:1>]<EOL>pos = pos - <NUM_LIT:1><EOL><DEDENT>arr[pos] = cursor<EOL>if simulation:<EOL><INDENT>iteration = iteration + <NUM_LIT:1><EOL>print("<STR_LIT>",iteration,"<STR_LIT::>",*arr)<EOL><DEDENT><DEDENT>return arr<EOL>
Insertion Sort
        Complexity: O(n^2)