Insertion sort Pseudo code vs implementation? So I'm trying to implement an insertion sort algorithms based on page 18 Cormen psuedocode but I'm confused by for j = 2 to A:length. Specifically, what does the j=2 mean? I'm implementing it using the below python code and it only works when the range is the entire length of the array:
def insertion_sort(arr):
    # length of array
    n = len(arr)

    # traverse through array
    for i in range(n):
        key = arr[i]
        j = i - 1
        while j &gt;= 0 and key &lt; arr[j]:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = key

Could someone explain?
The following two points might clear your confusion.

The pseudocode in the book is following $1$ based indexing. Your code is following $0$ based indexing.

Your code is technically doing nothing in the first iteration of the while loop. In the first iteration $i = 0$, therefore $j = -1$. Since $j&lt;0$, the inside while loop is not executed. And it keeps $A[0] = key$ to its original value. Effectively, your code starts executing from $i = 1$, which is equivalent to $j = 2$ in CLRS implementation.